Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- // ############################################## RealTime-Test orders ################################################
- #region Real-Time Test
- // vars:
- // RTTest(false),
- // intrabarpersist LastDir(0),
- // Test_LongEntry(false),
- // Test_ShortReverse(false),
- // Test_ShortReverseLimit(false),
- // Test_ShortEntry(false),
- // Test_LongReverse(false),
- // Test_LongExit1(false),
- // Test_LongExit1Pct(100),
- // Test_LongExit2(false),
- // Test_LongExit2Pct(60),
- // Test_LongExit3(false),
- // Test_LongExit3Pct(100),
- // Test_ShortExit1(false),
- // Test_ShortExit1Pct(100),
- // Test_ShortExit2(false),
- // Test_ShortExit2Pct(60),
- // Test_ShortExit3(false),
- // Test_ShortExit3Pct(100),
- // RTExitShares(0),
- // intrabarpersist PrevRT(false),
- // intrabarpersist HistPositionCleared(false),
- // intrabarpersist Test_LongEntryPlaced(false), DateTime Test_LongEntryDT(null),
- // intrabarpersist Test_ShortEntryPlaced(false), DateTime Test_ShortEntryDT(null),
- // intrabarpersist Test_ShortReversePlaced(false),
- // intrabarpersist Test_LongReversePlaced(false),
- // intrabarpersist Test_LongExit1Placed(false), DateTime Test_LongExit1DT(null),
- // intrabarpersist Test_LongExit2Placed(false), DateTime Test_LongExit2DT(null),
- // intrabarpersist Test_LongExit3Placed(false),
- // intrabarpersist Test_ShortExit1Placed(false), DateTime Test_ShortExit1DT(null),
- // intrabarpersist Test_ShortExit2Placed(false), DateTime Test_ShortExit2DT(null),
- // intrabarpersist Test_ShortExit3Placed(false),
- // intrabarpersist LimitSSOn(false);
- if RTTest and RT then begin
- if PrevRT = false then begin
- if MarketPosition=1 then
- order_Exit("RT Exit LX", 0, 0)
- else if MarketPosition=-1 then
- order_Exit("RT Exit SX", 0, 0);
- end;
- if MarketPosition=0 then
- HistPositionCleared = true;
- if Test_LongEntry and Test_LongEntryPlaced = false and
- (Test_ShortEntry = false or (Test_ShortExit1Placed and SecondsElapsed(Test_ShortExit1DT) >= 10)) and
- MarketPosition=0
- then begin
- if LONG_allowed then begin
- order_Exit("RT Test LE", 0, 0);
- LastDir = 1;
- Test_LongEntryPlaced = true;
- Test_LongEntryDT = DateTime.Now;
- end;
- end;
- if Test_ShortEntry and Test_ShortEntryPlaced = false and
- //(Test_LongEntry = false or Test_LongExit1Placed) and
- MarketPosition=0
- then begin
- if SHORT_allowed then begin
- order_Exit("RT Test SE", 0, 0);
- LastDir = -1;
- Test_ShortEntryPlaced = true;
- Test_ShortEntryDT = DateTime.Now;
- end;
- end;
- if LastDir = 1 and Test_ShortReverse and Test_ShortReversePlaced = false and
- (Test_LongEntryPlaced or Test_LongReversePlaced) and MarketPosition=1 and
- SecondsElapsed(Test_LongEntryDT) >= 10
- then begin
- if SHORT_allowed then begin
- if Test_ShortReverseLimit then
- LimitSSOn = true
- else
- order_Exit("RT Reverse SE", 0, 0);
- LastDir = -1;
- Test_ShortReversePlaced = true;
- Test_ShortEntryDT = DateTime.Now;
- Test_LongReversePlaced = false;
- end;
- end
- else if LastDir = -1 and Test_LongReverse and Test_LongReversePlaced = false and
- (Test_ShortEntryPlaced or Test_ShortReversePlaced) and MarketPosition=-1 and
- SecondsElapsed(Test_ShortEntryDT) >= 10
- then begin
- if LONG_allowed then begin
- order_Exit("RT Reverse LE", 0, 0);
- LastDir = 1;
- Test_LongReversePlaced = true;
- Test_LongEntryDT = DateTime.Now;
- Test_ShortReversePlaced = false;
- end;
- end;
- if LimitSSOn then
- if SHORT_allowed then begin
- order_Exit("RT Reverse Lmt SE", 0, close + 2 * tick);
- end;
- if Test_LongExit1 and Test_LongExit1Placed = false and
- Test_LongEntryPlaced and MarketPosition=1 and
- SecondsElapsed(Test_LongEntryDT) >= 10
- then begin
- if LONG_allowed then begin
- RTExitShares = IntPortion(currentshares * Test_LongExit1Pct * 0.01);
- order_Exit("RT Exit1 LX", RTExitShares, 0);
- order_Exit("RT Test LE2", 0, 0);
- Test_LongExit1Placed = true;
- Test_LongExit1DT = DateTime.Now;
- end;
- end;
- if Test_LongExit2 and Test_LongExit2Placed = false and
- Test_LongExit1Placed and MarketPosition=1 and
- SecondsElapsed(Test_LongExit1DT) >= 10
- then begin
- RTExitShares = IntPortion(currentshares * Test_LongExit2Pct * 0.01);
- order_Exit("RT Exit2 LX", RTExitShares, 0);
- Test_LongExit2Placed = true;
- Test_LongExit2DT = DateTime.Now;
- end;
- if Test_LongExit3 and Test_LongExit3Placed = false and
- Test_LongExit2Placed and MarketPosition=1 and
- SecondsElapsed(Test_LongExit2DT) >= 10
- then begin
- RTExitShares = IntPortion(currentshares * Test_LongExit3Pct * 0.01);
- order_Exit("RT Exit3 LX", RTExitShares, 0);
- Test_LongExit3Placed = true;
- end;
- if Test_ShortExit1 and Test_ShortExit1Placed = false and
- Test_ShortEntryPlaced and MarketPosition=-1 and
- SecondsElapsed(Test_ShortEntryDT) >= 10
- then begin
- if SHORT_allowed then begin
- RTExitShares = IntPortion(currentshares * Test_ShortExit1Pct * 0.01);
- order_Exit("RT Exit1 SX", RTExitShares, 0);
- order_Exit("RT Test SE2", 0, 0);
- Test_ShortExit1Placed = true;
- Test_ShortExit1DT = DateTime.Now;
- end;
- end;
- if Test_ShortExit2 and Test_ShortExit2Placed = false and
- Test_ShortExit1Placed and MarketPosition=-1 and
- SecondsElapsed(Test_ShortExit1DT) >= 10
- then begin
- RTExitShares = IntPortion(currentshares * Test_ShortExit2Pct * 0.01);
- order_Exit("RT Exit2 SX", RTExitShares, 0);
- Test_ShortExit2Placed = true;
- Test_ShortExit2DT = DateTime.Now;
- end;
- if Test_ShortExit3 and Test_ShortExit3Placed = false and
- Test_ShortExit2Placed and MarketPosition=-1 and
- SecondsElapsed(Test_ShortExit2DT) >= 10
- then begin
- RTExitShares = IntPortion(currentshares * Test_ShortExit3Pct * 0.01);
- order_Exit("RT Exit3 SX", RTExitShares, 0);
- Test_ShortExit3Placed = true;
- end;
- end;
- #endregion
- }
- ========================== orders ========================================
- //
- else if (name= "RT Test LE2" ) then
- buy ( "RT Test LE2" ) next bar at market
- else if (name= "RT Test SE2" ) then
- sell short( "RT Test SE2" ) next bar at market
- else if (name= "RT Exit1 LX" ) then
- sell ( "RT Exit1 LX" ) sharesNum shares next bar at market
- else if (name= "RT Exit1 SX" ) then
- buy to cover("RT Exit1 SX" ) sharesNum shares next bar at market
- else if (name= "RT Exit2 LX" ) then
- sell ( "RT Exit2 LX" ) sharesNum shares next bar at market
- else if (name= "RT Exit2 SX" ) then
- buy to cover("RT Exit2 SX" ) sharesNum shares next bar at market
- else if (name= "RT Exit3 LX" ) then
- sell ( "RT Exit3 LX" ) sharesNum shares next bar at market
- else if (name= "RT Exit3 SX" ) then
- buy to cover("RT Exit3 SX" ) sharesNum shares next bar at market
- //
- else if (name= "RT Exit LX" ) then
- sell( "RT Exit LX" ) next bar at market
- else if (name= "RT Exit SX" ) then
- buy to cover("RT Exit SX" ) next bar at market
- else if (name= "LX Sess_End" ) then
- sell ( "LX Sess_End" ) this bar on close
- else if (name= "SX Sess_End" ) then
- buy to cover("SX Sess_End" ) this bar on close
- //
- else if (name= "LX Break" ) then
- sell ( "LX Break" ) this bar on close
- else if (name= "SX Break" ) then
- buy to cover("SX Break" ) this bar on close
- //
- else if (name= "RT Test LE" ) then
- buy ( "RT Test LE" ) next bar at market
- else if (name= "RT Test SE" ) then
- sell short( "RT Test SE" ) next bar at market
- else if (name= "RT Reverse SE" ) then
- sell short( "RT Reverse SE" ) next bar at market
- else if (name= "RT Reverse LE" ) then
- buy ( "RT Reverse LE" ) next bar at market
- else if (name= "RT Reverse Lmt SE") then
- sell short( "RT Reverse Lmt SE") next bar at price limit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement