Search the docs for "static" variables.
VL is defined globally, I set it as static but still it remains unchanged even after balance doubles. If a variable is defined globally and given a value globally can it not be changed? as it will revert to its globally defined value?
I want to double the volume as soon as balance doubles, I tried the following code OnTick but it doesn't change the volume even after balance is over 20000. I also understand that this code will keep on adding 2.5 to the volume every tick as long as balance stays above 20000.
How do I write the code to achieve what I stated? Thank you in advance.
your code is true and should work!
extern double VL=0.1; void OnTick() { double balance=AccountInfoDouble(ACCOUNT_BALANCE); if(balance>20000) VL*=2; }
try this one
i checked and its working
your code is true and should work!
try this one
i checked and its working
or
VL+=2.5;
and dont forget OnTick() function
your code is true and should work!
try this one
i checked and its working
I found a much better way to do this using a while loop. The following code upsizes by executing the same trade again for each time the balance increases by 10000. It also automatically downsizes by not executing the trades if balance lowers.
void UpsizingLONG() { double balance=AccountInfoDouble(ACCOUNT_BALANCE); double BID=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits); double ASK=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits); while(balance > 20000) { balance = (balance-10000); trade.Buy(buyorderVL,_Symbol,ASK,ASK - buyorderSL,ASK + buyorderTP); } }
I found a much better way to do this using a while loop. The following code upsizes by executing the same trade again for each time the balance increases by 10000. It also automatically downsizes if balance lowers.
***
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to double the volume as soon as balance doubles, I tried the following code OnTick but it doesn't change the volume even after balance is over 20000. I also understand that this code will keep on adding 2.5 to the volume every tick as long as balance stays above 20000.
How do I write the code to achieve what I stated? Thank you in advance.