Spread value conditional

Posted By: ech87

Spread value conditional - 11/20/17 07:25

Hi There,

Im totally new to zorro and pretty bad at programming in general.

How can I create an on tick trade conditional that takes into account the spread.

For example i've tried:

function tick(){
if(Spread < 5){
[trading code goes here];
}
}

But when I try that with a simple long order, linked with and Mt4 account my orders go berserk and don't take into account the spread conditional at all?

Thanks!
Posted By: Spirit

Re: Spread value conditional - 11/20/17 07:42

Look good, the spread condition look ok to me and certainly not like beginner.

But I know no stock where spread is 5, spread is normally 0.01 or 0.0005 or so. Maybe you mean 5 pips? Also you should have another condition aside from spread, or else your code will open 1000 trades very quick.
Posted By: ech87

Re: Spread value conditional - 11/20/17 07:58

Thanks Spirit, I had some basic JavaScript expxerience in the past blush

The code still buys like crazy on tick if I set the value to < 0

e.g:

function tick(){
if(Spread = 0){
enterLong();
}
}

I think it's buying on tick, because it seems irregular in it's buying - but still atleast 1 order a second which makes me think it's ignoring the Spread conditional?

Nvm, i figured it out! You were right, I was being dumb eek

© 2024 lite-C Forums