NexusFi: Find Your Edge


Home Menu

 





Can you help me write strategy for tradestation


Discussion in EasyLanguage Programming

Updated
    1. trending_up 493 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Can you help me write strategy for tradestation

  #1 (permalink)
Stepanyan88
Erevan Erevan Armenia
 
Posts: 6 since Oct 2023
Thanks Given: 1
Thanks Received: 0

The adviser remembers the closing of the previous day. At the opening of the next day, if the price is higher than the closing of the previous day, we buy and put a stop. if the price is lower than the closing of the previous day, we shell and put a stop. If the stop is working revers positin. Close position end of day

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Exit Strategy
NinjaTrader
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Bigger Wins or Fewer Losses?
24 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #2 (permalink)
 
Trend Trader's Avatar
 Trend Trader 
Meridian, MS
 
Experience: Advanced
Platform: NinjaTrader, MotiveWave
Broker: Stage 5 Trading, TradeStation, NinjaTrader
Trading: NQ
Frequency: Several times daily
Duration: Minutes
Posts: 54 since Jan 2023
Thanks Given: 26
Thanks Received: 47


Stepanyan88 View Post
The adviser remembers the closing of the previous day. At the opening of the next day, if the price is higher than the closing of the previous day, we buy and put a stop. if the price is lower than the closing of the previous day, we shell and put a stop. If the stop is working revers positin. Close position end of day

If you have not tried the TradeStation forum, I would try your strategy request there. They have an employee that will write code for forum members. He gave me the code for a similar strategy that would buy on open with an X number of points gap down. The timed exit was variable as well as the gap and the stop.

Reply With Quote
Thanked by:
  #3 (permalink)
Stepanyan88
Erevan Erevan Armenia
 
Posts: 6 since Oct 2023
Thanks Given: 1
Thanks Received: 0


Can you halp me correct tis code stop and revers




Inputs:
StopPercent(1); // Stop loss percentage

Variables:
PrevClose(0),
StopPrice(0);

If Date <> Date[1] then
PrevClose = CloseD(1);

// Buy condition
If Close > PrevClose then
begin
Buy ("Long") next bar at market;
StopPrice = Close - (Close * StopPercent / 100);
end;

// Sell condition
If Close < PrevClose then
begin
SellShort ("Short") next bar at market;
StopPrice = Close + (Close * StopPercent / 100);
end;

// Check for stop loss
If MarketPosition = 1 and Low <= StopPrice then
begin
Sell ("Sell Stop") next bar at StopPrice at stop;
BuyToCover ("Reverse to Short") next bar at market;
end;

If MarketPosition = -1 and High >= StopPrice then
begin
BuyToCover ("Cover Buy Stop") next bar at StopPrice at stop ;
Buy ("Reverse to Long") next bar at market;
end;




// Close positions at the end of the day
If Time = 2300 then
Sell ("Clo Long") next bar at market;

If Time = 2300 then
BuyToCover ("Clo Short") next bar at market;

Reply With Quote
  #4 (permalink)
 TraderDoc2 
Plainview
 
Experience: Intermediate
Platform: TradeStation
Broker: TradeStation
Trading: Futures
Posts: 34 since Mar 2012
Thanks Given: 1
Thanks Received: 21

Say that you are using 5 minute price bars.

Then you could use this code:

 
Code
Inputs:
	StopPercent(0.5),  // Stop loss percentage
	NumShares(1),      // Number of Shares or Contracts
	CloseTm(2255);    // {Close Position at this Time ***** Recommend the Close Time of the Next to last price bar of the session; Must be before the actual session close time ******* }

Variables:
        RevStop(-999);


// Buy condition
If MarketPosition = 0 and Close > CloseD(1) then
begin
	If Time < CloseTm then Buy ("LE1") NumShares Shares next bar at market;
end;

// Sell condition
If MarketPosition = 0 and Close < CloseD(1) then
begin
	If Time < CloseTm then SellShort ("SE1") NumShares Shares next bar at market;
end;

If MarketPosition > 0 then 
begin
	If BarsSinceEntry = 0 then 
	begin
		RevStop =  EntryPrice * (1 - StopPercent/100);
	end;
	If Time < CloseTm then Sell Short("SE2") NumShares Shares next bar at RevStop stop;
end;

If MarketPosition < 0 then  
begin
	If BarsSinceEntry = 0 then
	begin
		RevStop = EntryPrice * (1 + StopPercent / 100);
	end;
	If Time < CloseTm then Buy ("LE2") NumShares Shares next bar at RevStop stop ;
end;

// Close positions at the end of the day
If Time >= CloseTm then begin
	Sell ("Clo Long") next bar at market;
	BuyToCover ("Clo Short") next bar at market;
end;

SetExitOnClose; // Needed for holiday shortened trade days

Follow me on Twitter Reply With Quote
  #5 (permalink)
Stepanyan88
Erevan Erevan Armenia
 
Posts: 6 since Oct 2023
Thanks Given: 1
Thanks Received: 0

Thank you very much

Reply With Quote




Last Updated on December 22, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts