Good luck.
You didn't specify a language so it's hard to give a answer in code.
But you can monitor the number of open positions and once a SL get's hit this number will change and you can use that moment in time to see what position closed and open new opposing positions if need be.
You didn't specify a language so it's hard to give a answer in code.
But you can monitor the number of open positions and once a SL get's hit this number will change and you can use that moment in time to see what position closed and open new opposing positions if need be.
I'm sorry, completely forgot about it. The language is MQL5. Alright, I'm going to try that too. Thank you for answering.
Won't work in the USA as hedging isn't allowed. Even one tick away might not.
Won't work in the USA as hedging isn't allowed. Even one tick away might not.
Won't work in the USA as hedging isn't allowed. Even one tick away might not.
How is a pending order that get filled as soon as an opposite position closed, considered as hedging ?
Enlighten me
please ...
Hi everyone!
So basically I'm coding an EA that places one trade depending on a given signal, and that trade runs just perfect. It places the trade when it should, and it changes the stop loss to breakeven once the first take profit target is hit.
I want to code it so if the stop loss is hit instead, it places a trade in the opposite direction, and if that stop loss is hit, it places another trade in the opposite direction again. For example, the first trade is a Long, the stop loss is hit so it places a Short, that stop loss is also hit so it places a Long.
So far I've been successful at coding the first order, but I can't quite figure out how to check if the stop loss is hit, and place the second trade, the third, fourth, and so on.
I don't have problems with the coding itself, but I'm struggling with the logic of the programm.
Lets say the first trade is a long trade. Once that first trade opens, it sets a boolean longTrade to true, and if the stop loss is hit, it sets the SLHit boolean to true, the longTrade boolean to false, and the shortTrade boolean to true.
Any ideas on a better way to do this?
You can create a OnTrade event. When any position is closed, if profit < 0 open a new opposite position.
How is a pending
order that get filled as soon as an opposite position closed, considered as hedging ?
Enlighten me
please ...
Hi everyone!
So basically I'm coding an EA that places one trade depending on a given signal, and that trade runs just perfect. It places the trade when it should, and it changes the stop loss to breakeven once the first take profit target is hit.
I want to code it so if the stop loss is hit instead, it places a trade in the opposite direction, and if that stop loss is hit, it places another trade in the opposite direction again. For example, the first trade is a Long, the stop loss is hit so it places a Short, that stop loss is also hit so it places a Long.
So far I've been successful at coding the first order, but I can't quite figure out how to check if the stop loss is hit, and place the second trade, the third, fourth, and so on.
I don't have problems with the coding itself, but I'm struggling with the logic of the programm.
Lets say the first trade is a long trade. Once that first trade opens, it sets a boolean longTrade to true, and if the stop loss is hit, it sets the SLHit boolean to true, the longTrade boolean to false, and the shortTrade boolean to true.
Any ideas on a better way to do this?
Specify - "if Stop Loss worked" - what do you mean? "Stop Loss worked and LOSS was received" or "Stop Loss worked and profit was received"?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone!
So basically I'm coding an EA that places one trade depending on a given signal, and that trade runs just perfect. It places the trade when it should, and it changes the stop loss to breakeven once the first take profit target is hit.
I want to code it so if the stop loss is hit instead, it places a trade in the opposite direction, and if that stop loss is hit, it places another trade in the opposite direction again. For example, the first trade is a Long, the stop loss is hit so it places a Short, that stop loss is also hit so it places a Long.
So far I've been successful at coding the first order, but I can't quite figure out how to check if the stop loss is hit, and place the second trade, the third, fourth, and so on.
I don't have problems with the coding itself, but I'm struggling with the logic of the programm.
Lets say the first trade is a long trade. Once that first trade opens, it sets a boolean longTrade to true, and if the stop loss is hit, it sets the SLHit boolean to true, the longTrade boolean to false, and the shortTrade boolean to true.
Any ideas on a better way to do this?