Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am at my witts end, simple MACD Cross over strategy
Below is the complete code I wrote for a simple MACD Cross over strategy (long) I then reversed the logic on the Buy sell entry trigger to have a short Strategy. It does not work and I am at my witts end ready to pull my hair our. I need your help to look it over and tell me whereI went wrong on the sgort strategy. I hear how robust the Sierra Language is but it seems extremely tempermental. I have added one line of code to a strategy-- just on line and it completely changes the functionality of the code. It almost seems illogical. Someone please help me and clue me in.
// Get the Internal Position data to be used for position exit processing.
s_SCPositionData InternalPositionData;
sc.GetInternalPosition(InternalPositionData) ;
float LastTradePrice = sc.Close[sc.Index];
// Create an s_SCNewOrder object.
s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = Order_qty; //Total contracts
NewOrder.OrderType = SCT_MARKET;
int cnt=0;
int i = sc.Index;
int Result;
int status = sc.GetBarHasClosedStatus(sc.UpdateStartIndex);
// Get the Internal Position data to be used for position exit processing.
s_SCPositionData InternalPositionData;
sc.GetInternalPosition(InternalPositionData) ;
float LastTradePrice = sc.Close[sc.Index];
// Create an s_SCNewOrder object.
s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = Order_qty; //Total contracts
NewOrder.OrderType = SCT_MARKET;
int cnt=0;
int i = sc.Index;
int Result;
int status = sc.GetBarHasClosedStatus(sc.UpdateStartIndex);
I know exactly how you are feeling. But the answer is as simple as this. If the idiom wits' end, has just one t in it and you type two t's, a human knows exactly what you mean. However one character "off" in your script can ruin the entire script.
Get someone who uses that like @vegasfoster involved.
Second, if you have an editor on your platform, can you "find all, change all"? Go back and use that to retry the language you changed to create the sell side. Probably missing a single character or something real simple.
No worries though man, someone withe a fresh set of eyes will see it right away.
@ wildman.....withe
i could not help myself, seems this was intentional.
maybe one day i need to start learning how to program.
@ tomlryde.....i hope you can get this working like you want man.
It looks like you have two different strategies in the same file, is that correct? Cuz I'm pretty sure you can't do that. For example, you can't define two different subgraph[0] etc. in the same file. Create separate sections for long and short entry/exit criteria, but create one contiguous set of subgraphs, inputs, and configuration defaults.
Just a note on long/short entries and exits, if you are reversing, then you don't need to both exit the open position and enter the new position, just enter the new position and the open position will be closed automatically.
Computers do exactly what you tell them to do, so even a single character can screw up any program, regardless of the platform. The easiest way to code is to start with existing code that that's similar to what you want to do and then change it one line or one section at a time. Edit, compile, test, edit, compile, test, etc. Then you will know exactly where any problems lye.
Thanks for your reply. I failed to mention that I have two strategies posed above. the first is a long cross over which works just fine. the second is the exact same strategy only I reversed the logic on the cross over and it does not work. Listed is the complete code so anyone who wants to can load it and compile it to see what happens. So I am really frustrated.
Thanks again
Way way back when the days of formal education where less of a distant fog, I had an English professor that inspired me to use items like the "withe" in my writing. I forgot the term, but doing that which I was using to make a point in context to reinforce and add levity, has a name.
You, being the first to notice or the first to point it out separate yourself from the crowd. You have a high level of acuity, that should be a great advantage in many things.
@vegasfoster is a crafty guy, although he does still live in his moms basement, I bet he can whip this issue in no time...come on vegas!