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:458 / 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 100,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 03: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)

July Journal Challenge - $500 in Amazon Gift Cards!

July
 

AXESS Trader: Powerful Cloud Based Trading Platform w/GFF Brokers

Jul 17

TBA: FuturesTrader71 w/Morad Askar

Elite only
     

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


All times are GMT -4. The time now is 05:41 AM. (this page content is cached, log in for real-time version)

Copyright © 2018 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 2018-07-18 in 0.09 seconds with 14 queries on phoenix