I need code, for example:
The bot performs a losing trade on dax at 12920.
The bot should never again trade in a range of 0.10% above and below 12920 … that is, it should never trade in the 12907-12933 range again.
Sorry managers for the previous post, problem with traductor again.
There you go (not tested):
Once PerCent = 0.10 //10%
Once LOrange = 0
Once HIrange = 9999999
If StrategyProfit >= StrategyProfit[1] Then
LOrange = 0
HIrange = 9999999
Endif
EntryConditions = 1
EntryConditions = ((Not ((close >= LOrange) and (close <= HIrange))) And LOrange <> 0)
If MyLongConditions and EntryConditions Then
Buy 1 contract at Market
Set Stop pLoss 100
Set Target pProfit 100
LOrange = close - (close * PerCent)
HIrange = close + (close * PerCent)
Endif
Ok Roberto.
But, with other losser operations.
In backtest are 31 losser operations.
I want no entry new operations on 31 differents ranges.
The correct code is (still not tested):
Once PerCent = 0.10 //10%
Once LOrange = 0
Once HIrange = 9999999
If StrategyProfit >= StrategyProfit[1] Then
LOrange = 0
HIrange = 9999999
Endif
EntryConditions = 1
If LOrange <> 0 Then
If ((close >= LOrange) and (close <= HIrange)) Then
EntryConditions = 0
Endif
Endif
If MyLongConditions and EntryConditions Then
Buy 1 contract at Market
Set Stop pLoss 100
Set Target pProfit 100
LOrange = close - (close * PerCent)
HIrange = close + (close * PerCent)
Endif
This Code is correct to all bad positivos un backtest???
Tomorrow see.
Sorry…
Yo all bad trades of backtest???
This Codes no function, Roberto!
I found the bug, this works (tested on Dax, Daily TF):
Once PerCent = 0.10 //10%
Once LOrange = 0
Once HIrange = 9999999
EntryConditions = 1
If LOrange <> 0 Then
If ((close >= LOrange) and (close <= HIrange)) Then
EntryConditions = 0
Endif
Endif
MyLongConditions = (Not OnMarket) AND (close > average[10,0](close))
If MyLongConditions and EntryConditions Then
Buy 1 contract at Market
Set Stop pLoss 1000
Set Target pProfit 1000
LOrange = close - (close * PerCent)
HIrange = close + (close * PerCent)
Endif
//graphonprice HIrange coloured(0,255,0,255)
//graphonprice LOrange coloured(255,0,0,255)
As you can see from the screenshot, the strategy stops trading, even if above average within the range, until it’s broken.
Ok Roberto, thanks!
I see this night or tomorrow.