Sierra Chart coding - how to call a function only once - Sierra Chart | futures io social day trading
futures io futures trading


Sierra Chart coding - how to call a function only once
Updated: Views / Replies:378 / 1
Created: by Oysteryx Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Sierra Chart coding - how to call a function only once

  #1 (permalink)
Elite Member
New York, NY
 
Futures Experience: Master
Platform: Various
Favorite Futures: Everything that moves
 
Oysteryx's Avatar
 
Posts: 217 since Feb 2014
Thanks: 340 given, 462 received

Sierra Chart coding - how to call a function only once

I need to run a s_SCNewOrder function only once, upon certain condition being met the first time only (for example price greater than X).

I have been looking at ways to achieve that in C++ (this thread for example c++ - How to make sure a function is only called once - Stack Overflow) but not sure yet how to implement this in ACSIL.

Would anyone here know?

Reply With Quote
 
  #2 (permalink)
Elite Member
New York, NY
 
Futures Experience: Master
Platform: Various
Favorite Futures: Everything that moves
 
Oysteryx's Avatar
 
Posts: 217 since Feb 2014
Thanks: 340 given, 462 received

Here is a simplified version of the code

SCENARIO = THERE IS A LONG POSITION WITH AN ATTACHED STOP BELOW

bool flag = true;

//Find PreExistingStop ID
s_SCTradeOrder PreExistingStop;
int StopResult = sc.GetNearestStopOrder(PreExistingStop);
int PreExistingStopOrderID = PreExistingStop.InternalOrderID;

//Get position data
s_SCPositionData PositionData;
sc.GetTradePosition(PositionData);

//Run the following only on the most recent bar
if (sc.Index == sc.ArraySize - 1)
{

//this says execute if flag=true and the distance between the high and the PositionData.AveragePrice is >= 10
if (((max(sc.High[sc.Index],sc.High[sc.Index-1]) - PositionData.AveragePrice) >= 10))
&& flag)
{

int Result = sc.CancelOrder(PreExistingStop.InternalOrderID); // this cancels the PreExistingStop

if (Result > 0) // if PreExistingStop succesfully cancelled enter new sell stop at 1800 and make flag=false
{
s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = 1;
NewOrder.OrderType = SCT_ORDERTYPE_STOP;
NewOrder.TimeInForce = SCT_TIF_GTC;
NewOrder.Stop1Price = 1800;
int Result = sc.SellEntry(NewOrder);

flag = false;
}

}
}

Once the trigger is reached, if flag=true, that 1) cancels the preexisting stop, 2) creates a new stop at 1800, and 3) makes flag=false.

THIS WORKED.

Needed to tinker with the following to get it to work:
sc.AllowEntryWithWorkingOrders = true;
sc.AllowOnlyOneTradePerBar = false;
sc.AllowMultipleEntriesInSameDirection = true;


Last edited by Oysteryx; February 20th, 2016 at 04:55 PM.
Reply With Quote
The following user says Thank You to Oysteryx for this post:

Reply



futures io > > > > Sierra Chart coding - how to call a function only once

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sierra Chart ZB back adjusted historical chart missing data Big Mike Sierra Chart 3 January 7th, 2016 08:15 AM
Convert TradeStation XAverage function to Sierra code Renko123 Sierra Chart 15 April 5th, 2015 04:32 PM
Call Reload NinjaScript (F5) as a function. ozatrading NinjaTrader 4 September 13th, 2013 09:33 AM
Coding for BollingerPercent from Ninja to Sierra, can anyone help? hector24 Sierra Chart 9 January 8th, 2013 10:38 AM
call plot function from OnBarUpdate() baberg NinjaTrader Programming 2 September 24th, 2011 09:33 AM


All times are GMT -4. The time now is 11:02 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-11 in 0.07 seconds with 19 queries on phoenix via your IP 54.145.16.43