Hi.
I'd like to go a little further with the basic Stop Loss Signal.
As of now it stops out my futures contracts and then it will wait for another signal to enter a position again.
I'd like to be able to:
1. upon stop @ set amount reverse and double the position.
2. set a new stop loss for this position.
3. set a new profit target for this position.
can anyone tell me how to do this within the Stop Loss signal, or would i need to code a completely different signal?
Cheers.
Using Stop loss or custom EL code to reverse with extras
- TJ
- Posts: 7744
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
I see, so instead of a stop loss signal i should make a custom signal that:
1. figures out if it is in a long or short position currently.
2. at a set loss amount (say $1000) it sellshort or is 'buy' the opposite equivalent?
3. then set another stop loss for this position.
4. set a profit target for this position.
So it's basically programming a new signal, no?
I guess i have to wip out my EL essential book when i was with TS...
1. figures out if it is in a long or short position currently.
2. at a set loss amount (say $1000) it sellshort or is 'buy' the opposite equivalent?
3. then set another stop loss for this position.
4. set a profit target for this position.
So it's basically programming a new signal, no?
I guess i have to wip out my EL essential book when i was with TS...
-
- Posts: 100
- Joined: 17 Jul 2009
- Location: Germany
Here is a basic StopAndReverse that I´ve coded. Maybe it´s a starting point for you:
Code: Select all
input: StopAndReverseDollar(500);
If MarketPosition=1 and positionprofit < -StopAndReverseDollar then Sell Short ("StopAndReverseL") Next Bar at Market;
If MarketPosition=-1 and positionprofit < -StopAndReverseDollar then Buy ("StopAndReverseS") Next Bar at Market;
gt:
I'm having trouble differentiating the reversal (one time) trade from the rest.
What i mean is once this reversal is taken (and it seems to work fine in that regard, I need to have a stoploss of $1000 lets say. Unfortunatly when the StopAndReverseDollar amount is hit ($at 500 presently) then it reverses again.
I want this to be a once shot trade. If it fails @ a stop of $1000 then it is out, if it has a profit of $2000 then it is out too unless the overall strategy gives a signal and re-instates itself.
Also, I am having trouble 'doubling' the position. So if you have 1 long and this is activated then you have 2 short.
I'm having trouble differentiating the reversal (one time) trade from the rest.
What i mean is once this reversal is taken (and it seems to work fine in that regard, I need to have a stoploss of $1000 lets say. Unfortunatly when the StopAndReverseDollar amount is hit ($at 500 presently) then it reverses again.
I want this to be a once shot trade. If it fails @ a stop of $1000 then it is out, if it has a profit of $2000 then it is out too unless the overall strategy gives a signal and re-instates itself.
Also, I am having trouble 'doubling' the position. So if you have 1 long and this is activated then you have 2 short.
I know I'm asking alot here so I will try to be clear and I REALLY appreciate the help in advanced for people who are willing.
I will try and break it down so it is clear:
1. First use code such as :
2. But, Double the position (if one long, then 2 short).
3. And, Have a stop loss just for this trade of $X.
4. And, Have a Profit Target just for this trade of $X.
5. And, If original strategy calls to be back in a position then cancel this strategy and run the original strategy (if 2 short, then one long for example again).
I have all the time in the world as I know if I don't get help here then I will have to pay my programmer Which I do not mind doing, he is worth it. And besides, I'm still trying to test the autotrading through IB. It's taking a bit longer than i expected for the TS to IB/MC change...
Cheers.
I will try and break it down so it is clear:
1. First use code such as :
Code: Select all
input: StopAndReverseDollar(500);
If MarketPosition=1 and positionprofit < -StopAndReverseDollar then Sell Short ("StopAndReverseL") Next Bar at Market;
If MarketPosition=-1 and positionprofit < -StopAndReverseDollar then Buy ("StopAndReverseS") Next Bar at Market;
3. And, Have a stop loss just for this trade of $X.
4. And, Have a Profit Target just for this trade of $X.
5. And, If original strategy calls to be back in a position then cancel this strategy and run the original strategy (if 2 short, then one long for example again).
I have all the time in the world as I know if I don't get help here then I will have to pay my programmer Which I do not mind doing, he is worth it. And besides, I'm still trying to test the autotrading through IB. It's taking a bit longer than i expected for the TS to IB/MC change...
Cheers.
Ah.. one work around I found is to create a data1-data2
so
This code obviously doesn't work...
But from here i should be able to set a stop loss and profit target that is just for data 2.
thanks again in advance.
so
Code: Select all
[IntrabarOrderGeneration = false]
input: StopAndReverseDollar(670);
If (data1) MarketPosition=1 and (data1) positionprofit < -StopAndReverseDollar then Sell Short 2 contracts (data2) ("StopAndReverseL") Next Bar at Market;
If (data1) MarketPosition=-1 and (data1) positionprofit < -StopAndReverseDollar then Buy 2 contracts (data2) ("StopAndReverseS") Next Bar at Market;
But from here i should be able to set a stop loss and profit target that is just for data 2.
thanks again in advance.
- TJ
- Posts: 7744
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
- TJ
- Posts: 7744
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
I would suggest you to draw a flow chart...I know I'm asking alot here so I will try to be clear and I REALLY appreciate the help in advanced for people who are willing.
I will try and break it down so it is clear:
...
Cheers.
with branches for all the permutations.
you can then use the flow chart to visualize your logic.
coding with EasyLanguage is not difficult,
it is just tedious.
.