Hello all,
I wrote a super easy correlation strategy that looks to hold for 7 days after entry. uses daily bars.
the problem I'm having is if I'm currently in a position and i get another signal the second entry will exit the same time as the first.
how do i exit 7 days after each entry?
so that each individual entry is held for 7 bars regardless if another entry is initiated.
barssinceentry does not seem to work. it liquidates all entries after the initial ones 7 day mark.
how to have a time exit regardless the number of entrys [SOLVED]
how to have a time exit regardless the number of entrys
- Attachments
-
- Capture2.png
- (107.76 KiB) Downloaded 870 times
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: how to have a time exit regardless the number of entrys
scarecrow, please provide a sample code you are using for entry and exit orders.
Have you tried "sell from entry" command?
Have you tried "sell from entry" command?
Re: how to have a time exit regardless the number of entrys
I tried sell from entry. but that only seems to work at a maximum of 2 entries.scarecrow, please provide a sample code you are using for entry and exit orders.
Have you tried "sell from entry" command?
example: if a 3rd buy signal is initiated within the seven days of the 2nd, that 3rd buy signal is treated as another 2nd buy signal, instead of a 3rd. therefore the 3rd and any subsequent entries within the 7 day time frame exit the same as the second entry. I feel like i'm missing something easy. i would just like to be able to enter the market and hold for seven days no matter what other entries occur. i.e. if i buy separately on monday then tuesday then wednesday, mondays entry will sell next monday, tuesday entry will sell next tuesday etc...
very first and basic entry and exit code i have been messing with. the one from the chart
Code: Select all
//Longs
If marketposition <> -1 and (MyVolit < VltFilter )
and (close < Open) and (close data2 < open data2)
and ((Close - close[1]) / close[1] < (close data2 - close[1] data2) / close[1] data2)
{and ((Close - close[1]) / close[1] < PctChange)}
then
Begin
alert ("Buy This Bar or Tomorrow Open");
buy this bar close;
end;
//long exits
if marketposition <> 0 then
begin
if barssinceentry = BarToExitOn then
sell next bar at market;
end;
setstopshare;
if MarketPosition = 1 then
SetStopLoss( EntryPrice * StopLossPct )
else
Sell ( "PctStopLX-eb" ) next bar at Close * ( 1 - StopLossPct ) stop ;
-
- Posts: 186
- Joined: 10 May 2012
- Has thanked: 14 times
- Been thanked: 11 times
Re: how to have a time exit regardless the number of entrys
Here is the easy way...
Code: Select all
ForceCloseTime = 15:50;
if MarketPosition = 1 then
If Time < ForceCloseTime then begin
// put your normal share handling code here that works before your ForceTimeClose
end
else begin // code below here executes after ForceCloseTime
Sell ( "PctStopLX-eb" ) next bar at Market;
end;
Re: how to have a time exit regardless the number of entrys
I don't see how this code would apply with a daily bar chart...? i'll work with it tomorrow and try to understand it more. But could you elaborate how this would work?
Thanks KT
Thanks KT
Here is the easy way...
Code: Select all
ForceCloseTime = 15:50;
if MarketPosition = 1 then
If Time < ForceCloseTime then begin
// put your normal share handling code here that works before your ForceTimeClose
end
else begin // code below here executes after ForceCloseTime
Sell ( "PctStopLX-eb" ) next bar at Market;
end;
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: how to have a time exit regardless the number of entrys
Scarecrow, barssinceentry works as expected. Please try your script without exit price orders or put them under barssinceentry condition as well.
Re: how to have a time exit regardless the number of entrys
Hi Henry,
Not sure i follow.
I feel like i'm missing something easy. i would just like to be able to enter the market and hold for seven days no matter what other entries occur. i.e. if i buy separately on monday then tuesday then wednesday, mondays entry will sell next monday, tuesday entry will sell next tuesday etc... in this example barssensentry would have all the orders exit on the next monday.
Not sure i follow.
Barssenseentry does work, unless i have multiple orders. then they all exit after 7 days of the initial entry.Scarecrow, barssinceentry works as expected. Please try your script without exit price orders or put them under barssinceentry condition as well.
I feel like i'm missing something easy. i would just like to be able to enter the market and hold for seven days no matter what other entries occur. i.e. if i buy separately on monday then tuesday then wednesday, mondays entry will sell next monday, tuesday entry will sell next tuesday etc... in this example barssensentry would have all the orders exit on the next monday.
Re: how to have a time exit regardless the number of entrys
you have the option to Exit a part of you position by using the syntax:
where Size_Exit is a number that you Input or calculate as a Variable; and STOP_1 is a Variable that has been calculated.
Code: Select all
Sell ("STOP_1") Size_Exit Contracts Next Bar STOP_1 STOP ;
Last edited by escamillo on 20 Sep 2012, edited 1 time in total.
Re: how to have a time exit regardless the number of entrys
Hi Henry,
Not sure i follow.Barssenseentry does work, unless i have multiple orders. then they all exit after 7 days of the initial entry.Scarecrow, barssinceentry works as expected. Please try your script without exit price orders or put them under barssinceentry condition as well.
I feel like i'm missing something easy. i would just like to be able to enter the market and hold for seven days no matter what other entries occur. i.e. if i buy separately on monday then tuesday then wednesday, mondays entry will sell next monday, tuesday entry will sell next tuesday etc... in this example barssensentry would have all the orders exit on the next monday.
scarecrow,
Have a look at following tutorial to help you with your code.
http://markplex.com/free-tutorials/tuto ... id-trades/
Re: how to have a time exit regardless the number of entrys
thanks super, i love markplex. i'll check it out.Hi Henry,
Not sure i follow.Barssenseentry does work, unless i have multiple orders. then they all exit after 7 days of the initial entry.Scarecrow, barssinceentry works as expected. Please try your script without exit price orders or put them under barssinceentry condition as well.
I feel like i'm missing something easy. i would just like to be able to enter the market and hold for seven days no matter what other entries occur. i.e. if i buy separately on monday then tuesday then wednesday, mondays entry will sell next monday, tuesday entry will sell next tuesday etc... in this example barssensentry would have all the orders exit on the next monday.
scarecrow,
Have a look at following tutorial to help you with your code.
http://markplex.com/free-tutorials/tuto ... id-trades/