Thursday 1 February 2018

سفم نظام التداول


تعلم الآلة: كيف يمكن دعم آلات المتجهات يمكن استخدامها في التداول.


ما هي آلة دعم ناقلات؟


جهاز ناقل الدعم هو وسيلة للتعلم الآلي الذي يحاول أخذ بيانات المدخلات وتصنيفها في واحدة من فئتين. ولكي تكون آلة ناقل الدعم فعالة، من الضروري استخدام مجموعة من بيانات المدخلات والمخرجات التدريبية لبناء نموذج جهاز ناقل الحركة الذي يمكن استخدامه لتصنيف البيانات الجديدة.


وتطور آلة ناقلات الدعم هذا النموذج عن طريق أخذ مدخلات التدريب، ورسم خرائط لها في الفضاء متعدد الأبعاد، ثم استخدام الانحدار للعثور على مفرط (وهي عبارة عن سطح في الفضاء n الأبعاد، ويفصل بين الفضاء إلى نصف المسافات) الذي يفصل أفضل والفئتين من المدخلات. مرة واحدة وقد تم تدريب آلة ناقلات الدعم، وأنها قادرة على تقييم المدخلات الجديدة فيما يتعلق مفرطة فصل وتصنيفها في واحدة من الفئتين.


آلة ناقل الدعم هي في الأساس آلة الإدخال / الإخراج. يمكن للمستخدم أن يضع في المدخلات، واستنادا إلى نموذج وضعت من خلال التدريب، فإنه سيعود الناتج. عدد المدخلات لأي جهاز ناقل دعم معين يتراوح نظريا من واحد إلى ما لا نهاية، ولكن من الناحية العملية قوة الحوسبة لا تحد من عدد المدخلات التي يمكن استخدامها. على سبيل المثال، يتم استخدام المدخلات N لجهاز متجه دعم معين (القيمة الصحيحة لل N يمكن أن تتراوح من واحد إلى ما لا نهاية)، يجب على جهاز ناقل الدعم تعيين كل مجموعة من المدخلات في الفضاء N الأبعاد، والعثور على (N-1 ) - dimensional هيبيربلان أن أفضل يفصل البيانات التدريب.


الشكل 1. دعم آلات المتجهات هي آلات الإدخال / الإخراج.


أفضل طريقة لتصور كيف تعمل آلة دعم ناقلات هو النظر في حالة ثنائية الأبعاد. نفترض أننا نريد إنشاء جهاز ناقل الدعم الذي يحتوي على اثنين من المدخلات ويعود إخراج واحد الذي يصنف نقطة البيانات كما تنتمي إلى واحدة من فئتين. يمكننا تصور هذا عن طريق التآمر على الرسم البياني 2-الأبعاد مثل الرسم البياني أدناه.


الشكل 2. اليسار: دعم ناقلات آلة ناقلات تعيينها إلى الرسم البياني 2D. وتستخدم الدوائر الحمراء والصلبان الزرقاء للدلالة على فئتي المدخلات.


الشكل 3. الحق: دعم المدخلات آلة ناقلات تعيينها إلى الرسم البياني 2D. وتستخدم الدوائر الحمراء والصلبان الزرقاء للدلالة على فئتين من المدخلات مع خط أسود يشير إلى فصل مفرط.


في هذا المثال، تشير المعابر الزرقاء إلى نقاط البيانات التي تنتمي إلى الفئة 1 والدوائر الحمراء التي تمثل نقاط البيانات التي تنتمي إلى الفئة 2. كل نقطة من نقاط البيانات الفردية لها قيمة مدخلات فريدة من نوعها 1 (ممثلة بموقفها على المحور س ) وقيمة إدخال 2 فريدة (ممثلة بموقفها على المحور الصادي) وقد تم تعيين كل هذه النقاط إلى الفضاء ثنائي الأبعاد.


آلة ناقلات الدعم قادرة على تصنيف البيانات عن طريق إنشاء نموذج من هذه النقاط في 2 الفضاء الأبعاد. آلة ناقلات الدعم مراقبة البيانات في الفضاء 2 الأبعاد، ويستخدم خوارزمية الانحدار للعثور على 1 هيبيربلان الأبعاد (ويعرف أيضا باسم الخط) التي تفصل أكثر دقة البيانات إلى فئتين. ثم يتم استخدام خط الفصل هذا بواسطة جهاز ناقل الدعم لتصنيف نقاط البيانات الجديدة إلى الفئة 1 أو الفئة 2.


الرسوم المتحركة أدناه توضح عملية تدريب جهاز ناقل دعم جديد. سوف تبدأ الخوارزمية عن طريق جعل تخمين عشوائي العثور على لوحة مفرغة فصل، ثم بشكل متكرر تحسين دقة لوحة مفرغة. كما ترون الخوارزمية تبدأ بقوة جدا، ولكن بعد ذلك يبطئ كما يبدأ في الاقتراب من الحل رغبات.


الشكل 4. الرسوم المتحركة تظهر تدريب جهاز ناقل الدعم. وتتقارب الطفرة تدريجيا مع الهندسة المثالية لفصل فئتي البيانات.


السيناريو ثنائي الأبعاد أعلاه المقدمة يسمح لنا لتصور عملية آلة ناقلات الدعم، ومع ذلك فإنه هو فقط قادرة على تصنيف نقطة بيانات باستخدام اثنين من المدخلات. ماذا لو أردنا استخدام المزيد من المدخلات؟ الحمد لله، خوارزمية آلة ناقلات الدعم يسمح لنا أن نفعل الشيء نفسه في أبعاد أعلى، على الرغم من أنه يصبح من الصعب بكثير لتصور.


النظر في هذا، كنت ترغب في إنشاء دعم ناقلات الجهاز الذي يأخذ 20 المدخلات ويمكن تصنيف أي نقطة البيانات باستخدام هذه المدخلات في أي فئة 1 أو الفئة 2. من أجل القيام بذلك، تحتاج آلة ناقلات الدعم لنموذج البيانات في 20 الفضاء الأبعاد واستخدام خوارزمية الانحدار للعثور على 19 هيبيربلان الأبعاد التي تفصل نقاط البيانات إلى فئتين. هذا يصعب من الصعب تصور كما أنه من الصعب بالنسبة لنا أن نفهم أي شيء فوق 3 أبعاد، ولكن كل ما تحتاج إلى معرفته هو أن يعمل بنفس الطريقة تماما كما يفعل لحالة 2 الأبعاد.


كيف "دعم ناقلات آلات العمل"؟ مثال: هل هو سنيك؟


تخيل هذا السيناريو الافتراضي، كنت باحثا التحقيق في حيوان نادر فقط وجدت في أعماق القطب الشمالي دعا شنيكس. وبالنظر إلى بعد هذه الحيوانات، لم يتم العثور سوى حفنة صغيرة من أي وقت مضى (دعونا نقول حوالي 5000). كباحث، كنت عالقة مع هذا السؤال. كيف يمكنني تحديد سنيك؟


كل ما لديك تحت تصرفكم هي الأبحاث التي نشرت سابقا من قبل حفنة من الباحثين التي شهدت واحدة. في هذه الأبحاث، يصف المؤلفون خصائص معينة عن سنيكس وجدوا، أي الارتفاع والوزن وعدد الساقين، وما إلى ذلك ولكن كل هذه الخصائص تختلف بين الأوراق البحثية التي لا يوجد بها نمط ملحوظ.


كيف يمكننا استخدام هذه البيانات للتعرف على حيوان جديد باعتباره سنيك؟


أحد الحلول الممكنة لمشكلتنا هو استخدام آلة ناقلات الدعم لتحديد الأنماط في البيانات وإنشاء إطار عمل يمكن استخدامه لتصنيف الحيوانات على أنها سنيك أو لا سنيك. الخطوة الأولى هي إنشاء مجموعة من البيانات التي يمكن استخدامها لتدريب جهاز ناقلات الدعم لتحديد شنيكس. بيانات التدريب هي مجموعة من المدخلات والمخرجات مطابقة لآلة ناقلات الدعم لتحليل واستخراج نمط من.


ولذلك، يجب أن نقرر ما هي المدخلات التي سيتم استخدامها وكم. نظريا، يمكن أن يكون لدينا العديد من المدخلات كما نريد، ولكن هذا يمكن أن يؤدي في كثير من الأحيان إلى التدريب بطيئة (والمزيد من المدخلات لديك المزيد من الوقت الذي يستغرق آلة ناقلات الدعم لاستخراج أنماط). أيضا، كنت ترغب في اختيار المدخلات القيم التي تميل إلى أن تكون متسقة نسبيا عبر جميع شنيكس. على سبيل المثال، ارتفاع أو وزن الحيوان سيكون مثالا جيدا على المدخلات لأنك تتوقع أن هذا سيكون متسقا نسبيا في جميع سشنيكس. ومع ذلك، فإن متوسط ​​عمر الحيوان سيكون خيارا ضعيفا من المدخلات لأنك تتوقع سن الحيوانات التي تم تحديدها من شأنها أن تختلف اختلافا كبيرا.


ولهذا السبب، تم اختيار المدخلات التالية:


ارتفاع الوزن عدد الساقين عدد العيون طول الذراع الحيوان متوسط ​​سرعة الحيوانات تردد الحيوانات الدعوة التزاوج.


مع المدخلات المختارة، يمكننا أن نبدأ في تجميع بيانات التدريب لدينا. يجب أن تستوفي بيانات التدريب الفعالة لآلة ناقلات الدعم متطلبات معينة:


يجب أن يكون البيانات أمثلة من الحيوانات التي هي سنيكس يجب أن يكون البيانات أمثلة من الحيوانات التي ليست سنيكس.


في هذه الحالة لدينا أوراق بحثية من العلماء التي حددت بنجاح سنيك و سرد خصائصها. لذلك يمكننا قراءة هذه الأوراق البحثية واستخراج البيانات تحت كل من المدخلات وتخصيص مخرجات صحيحة أو خاطئة لكل من الأمثلة. قد تبدو بيانات التدريب في هذه الحالة مشابهة للجدول أدناه.


الجدول 1. مثال لجدول الملاحظات.


وبمجرد أن جمعنا البيانات لجميع المدخلات والمخرجات التدريبية لدينا، يمكننا استخدامه لتدريب لدينا ناقلات دعم الجهاز. خلال عملية التدريب، فإن آلة ناقلات الدعم إنشاء نموذج في سبعة أبعاد الفضاء التي يمكن استخدامها لفرز كل من الأمثلة التدريبية في إما صحيحة أو خاطئة. وستستمر آلة ناقلات الدعم في القيام بذلك إلى أن يكون لها نموذج يمثل بدقة بيانات التدريب (ضمن التسامح المحدد للخطأ). وبمجرد اكتمال التدريب، يمكن استخدام هذا النموذج لتصنيف نقاط بيانات جديدة إما صحيحة أو خاطئة.


هل آلة دعم الدعم في الواقع العمل؟


وباستخدام سينيك سنيك، قمت بكتابة نص برمجي يختبر مدى قدرة جهاز متجه الدعم على التعرف على سنيكس جديدة. للقيام بذلك، لقد استخدمت "دعم ناقلات آلة التعلم أداة" مكتبة مكتبة التي يمكن تحميلها من السوق.


لنموذج هذا السيناريو بشكل فعال، نحن بحاجة إلى أن تقرر أولا ما هي الخصائص الفعلية لل سنيك. وقد تم إدراج الخصائص التي افترضتها في هذه الحالة في الجدول أدناه. إذا كان الحيوان يفي بجميع المعايير أدناه، فإنه هو سنيك.


الجدول 2. ملخص المعلمات التي تحدد سنيك.


الآن بعد أن عرفنا سنيك لدينا، يمكننا استخدام هذا التعريف لتجربة آلات ناقلات الدعم. الخطوة الأولى هي إنشاء وظيفة قادرة على اتخاذ المدخلات السبعة لأي حيوان معين والعودة التصنيف الفعلي للحيوان كما سنيك أم لا. وسوف تستخدم هذه الوظيفة لتوليد بيانات التدريب للجهاز ناقلات الدعم وكذلك تقييم أداء منه في نهاية المطاف. ويمكن القيام بذلك باستخدام الدالة أدناه؛


والخطوة التالية في العملية هي إنشاء وظيفة يمكن أن تولد المدخلات والمخرجات التدريبية. سيتم إنشاء الإدخالات في هذه الحالة بإنشاء أرقام عشوائية ضمن نطاق محدد لكل من قيم الإدخال السبعة. ثم لكل من مجموعات من المدخلات العشوائية ولدت، سيتم استخدام الدالة إسيتاسشنيك () أعلاه لتوليد الناتج المطلوب المقابلة. ويتم ذلك في الوظيفة التالية:


لدينا الآن مجموعة من المدخلات والمخرجات التدريب، فقد حان الوقت الآن لإنشاء آلات ناقلات الدعم باستخدام "دعم ناقلات آلة التعلم أداة" المتاحة في السوق. مرة واحدة يتم إنشاء جهاز ناقل دعم جديد، فمن الضروري لتمرير مدخلات التدريب والمخرجات له وتنفيذ التدريب.


لدينا الآن آلة ناقلات الدعم التي تم تدريبها بنجاح في تحديد سنيكس. للتحقق من ذلك، يمكننا اختبار جهاز ناقل الدعم النهائي عن طريق طرحه لتصنيف نقاط بيانات جديدة. ويتم ذلك من خلال توليد المدخلات العشوائية أولا، ثم استخدام الدالة إسيتاسشنيك () لتحديد ما إذا كانت هذه المدخلات تتوافق مع سنيك الفعلي، ثم استخدام آلة ناقلات الدعم لتصنيف المدخلات وتحديد ما إذا كانت النتيجة المتوقعة تتطابق مع النتيجة الفعلية. ويتم ذلك في الوظيفة التالية:


أوصي اللعب مع القيم ضمن الوظائف المذكورة أعلاه لنرى كيف أداء ناقلات الدعم أداء في ظل ظروف مختلفة.


لماذا هو دعم ناقلات آلة مفيدة جدا؟


الاستفادة من استخدام آلة ناقلات الدعم لاستخراج نمط معقد من البيانات هو أنه ليس من الضروري فهم مسبق لسلوك البيانات. آلة ناقلات الدعم قادرة على تحليل البيانات واستخراج رؤى وعلاقات فقط. وبهذه الطريقة، فإنه يعمل على غرار مربع أسود تلقي المدخلات وتوليد الانتاج التي يمكن أن تكون مفيدة جدا في إيجاد أنماط في البيانات التي هي معقدة جدا وغير واضحة.


واحدة من أفضل ميزات آلات ناقلات الدعم هي أنها قادرة على التعامل مع الأخطاء والضوضاء في البيانات بشكل جيد للغاية. وغالبا ما تكون قادرة على رؤية النمط الأساسي داخل البيانات وتصفية القيم المتطرفة البيانات والتعقيدات الأخرى. النظر في السيناريو التالي، في إجراء البحوث الخاصة بك على سنيكس، كنت تأتي عبر العديد من الأبحاث التي تصف سنيكس مع خصائص مختلفة بشكل كبير (مثل سنيك الذي هو 200kg و 15000mm طويل القامة).


أخطاء مثل هذا يمكن أن يؤدي إلى تشوهات النموذج الخاص بك ما هو سنيك، والتي يمكن أن تسبب لك أن تجعل من الخطأ عند تصنيف اكتشافات سنيك جديدة. فائدة آلة ناقلات الدعم هي أنه سيتم تطوير نموذج يتفق مع النمط الأساسي المعارض لنموذج يناسب جميع نقاط بيانات التدريب. ويتم ذلك عن طريق السماح بمستوى معين من الخطأ في النموذج لتمكين آلة ناقل الدعم من التغاضي عن أي أخطاء في البيانات.


في حالة سنيك آلة ناقلات الدعم، إذا سمحنا تحمل الخطأ من 5٪، ثم التدريب سوف تحاول فقط لتطوير نموذج يتفق مع 95٪ من بيانات التدريب. وهذا يمكن أن يكون مفيدا لأنه يسمح للتدريب لتجاهل النسبة المئوية الصغيرة من القيم المتطرفة.


يمكننا التحقيق في هذه الخاصية من جهاز دعم ناقلات أخرى عن طريق تعديل السيناريو لدينا سنيك. وقد أضيفت الوظيفة أدناه لإدخال أخطاء عشوائية متعمدة في مجموعة بيانات التدريب لدينا. هذه الوظيفة سوف تختار نقاط التدريب عشوائيا واستبدال المدخلات والمخرجات المقابلة مع المتغيرات العشوائية.


هذه الوظيفة تسمح لنا لإدخال أخطاء متعمدة في بيانات التدريب لدينا. باستخدام هذا الخطأ شغل البيانات، يمكننا إنشاء وتدريب جديد ناقلات دعم الجهاز ومقارنة أدائها مع واحد الأصلي.


عند تشغيل البرنامج النصي، ينتج النتائج التالية في سجل الخبراء. ضمن مجموعة بيانات التدريب مع 5000 نقطة التدريب، كنا قادرين على إدخال 500 أخطاء عشوائية. عند مقارنة أداء هذا الخطأ شغل آلة ناقلات الدعم مع واحد الأصلي، يتم تقليل الأداء فقط من قبل & لوت؛ 1٪. وذلك لأن آلة ناقل الدعم قادرة على التغاضي عن القيم المتطرفة في مجموعة البيانات عند التدريب ولا تزال قادرة على إنتاج نموذج دقيق لافت للنظر من البيانات الحقيقية. ويشير هذا إلى أن آلات ناقلات الدعم يمكن أن تكون أداة أكثر فائدة في استخراج الأنماط المعقدة والأفكار من مجموعات البيانات الصاخبة.


الشكل 5. سجل الخبير الناتج بعد تشغيل السيناريو "سنيك" في ميتاتريدر 5.


يمكن تحميل النسخة الكاملة من التعليمات البرمجية أعلاه من قاعدة التعليمات البرمجية، ولكن لا يمكن تشغيل هذا البرنامج النصي إلا في المحطة الطرفية الخاصة بك إذا كنت قد اشتريت نسخة كاملة من أداة دعم آلة ناقلات الدعم من السوق. إذا كان لديك فقط نسخة تجريبية من هذه الأداة تحميلها، سوف تكون محدودة لاستخدام الأداة عن طريق اختبار الاستراتيجية. للسماح لاختبار رمز "سنيك" باستخدام الإصدار التجريبي من الأداة، لقد أعدت كتابة نسخة من البرنامج النصي إلى مستشار خبير يمكن نشرها باستخدام اختبار الاستراتيجية. يمكن تنزيل كل من هذين النسختين البرمجيتين باتباع الروابط أدناه:


النسخة الكاملة - باستخدام البرنامج النصي الذي يتم نشره في محطة ميتاتريدر 5 (يتطلب نسخة مشتراة من أداة دعم أداة ناقلات الدعم)


الإصدار التجريبي - استخدام مستشار الخبراء التي يتم نشرها في اختبار ميتاتريدر 5 استراتيجية (يتطلب فقط نسخة تجريبية من أداة دعم ناقلات الدعم أداة)


كيف يمكن دعم آلات المتجهات أن تستخدم في السوق؟


ومن المسلم به أن مثال سنيك الذي نوقش أعلاه بسيط جدا، ولكن هناك بعض أوجه الشبه التي يمكن استخلاصها بين هذا المثال واستخدام أجهزة ناقل الدعم لتحليل السوق التقنية.


التحليل الفني هو أساسا حول استخدام بيانات السوق التاريخية للتنبؤ بتحركات الأسعار في المستقبل. على نفس المنوال في المثال سنيك، كنا نستخدم الملاحظات التي أدلى بها العلماء الماضي للتنبؤ ما إذا كان حيوان جديد هو سنيك أم لا. وعلاوة على ذلك، يعاني السوق من الضوضاء والأخطاء والمتغيرات الإحصائية التي تجعل استخدام آلة ناقلات الدعم مفهوما للاهتمام.


وأساس عدد كبير من نهج التداول في التحليل التقني ينطوي على الخطوات التالية:


رصد عدة مؤشرات تحديد ما هي الشروط لكل مؤشر يرتبط مع احتمال التجارة الناجحة مشاهدة كل من المؤشرات وتقييم متى جميع (أو أكثر) مما يشير إلى التجارة.


ومن الممكن اعتماد نهج مماثل لاستخدام آلات ناقلات الدعم للإشارة إلى الصفقات الجديدة بطريقة مماثلة. وقد تم تطوير أداة التعلم آلة ناقلات الدعم مع هذا في الاعتبار. وصف كامل لكيفية استخدام هذه الأداة يمكن العثور عليها في السوق، ولذا فإنني سوف تعطي فقط لمحة سريعة. عملية استخدام هذه الأداة هي كما يلي:


الشكل 6. مخطط الرسم البياني يوضح عملية تنفيذ أداة دعم ناقلات الدعم في أحد مستشاري الخبراء.


قبل أن تتمكن من استخدام أداة دعم آلة ناقلات الدعم، من المهم أن نفهم أولا كيف يتم توليد مدخلات التدريب والمخرجات.


كيف يتم توليد مدخلات التدريب؟


لذا، تم بالفعل تهيئة المؤشرات التي تريد استخدامها كمدخلات بالإضافة إلى جهاز ناقل الحركة الجديد. الخطوة التالية هي تمرير مقابض المؤشر إلى جهاز ناقل الحركة الجديد الخاص بك وإرشاده حول كيفية إنشاء بيانات التدريب. يتم ذلك عن طريق استدعاء الدالة سيتانديكاتورهاندلز (). هذه الوظيفة تسمح لك لتمرير مقابض المؤشرات تهيئة في آلة ناقلات الدعم. ويتم ذلك عن طريق تمرير ومجموعة صحيحة تحتوي على مقابض. والمدخلان الآخران لهذه الوظيفة هو قيمة الإزاحة وعدد نقاط البيانات.


قيمة الإزاحة تشير إلى الإزاحة بين الشريط الحالي وشريط البداية لاستخدامها في توليد مدخلات التدريب وعدد نقاط التدريب (المشار إليها بواسطة N) يحدد حجم بيانات التدريب الخاصة بك. يوضح الرسم البياني أدناه كيفية استخدام هذه القيم. قيمة تخالف 4 وقيمة N من 6 سوف تخبر جهاز ناقل الدعم فقط باستخدام الأشرطة التي تم التقاطها في المربع الأبيض لإنشاء مدخلات التدريب والمخرجات. وبالمثل، فإن قيمة إزاحة 8 وقيمة N من 8 تخبر آلة ناقلات الدعم فقط استخدام الأشرطة التي تم التقاطها في المربع الأزرق لإنشاء مدخلات التدريب والمخرجات.


بمجرد استدعاء الدالة سيتينديكاتورهاندلز ()، يمكن استدعاء الدالة جينينبوتس (). ستستخدم هذه الوظيفة مقابض المؤشر لتمريرها لتوليد صفيف من بيانات المدخلات لاستخدامها في التدريب.


الشكل 7. مخطط شمعة يوضح قيم أوفست و N.


كيف يتم إنتاج مخرجات التدريب؟


يتم توليد مخرجات التدريب من خلال محاكاة الصفقات الافتراضية استنادا إلى بيانات الأسعار التاريخية وتحديد ما إذا كانت هذه التجارة كانت ناجحة أو غير ناجحة. من أجل القيام بذلك، هناك عدد قليل من المعلمات التي تستخدم لتعليم أداة دعم ناقلات الدعم أداة كيفية تقييم التجارة الافتراضية إما ناجحة أو غير ناجحة.


المتغير الأول هو OP_TRADE. قيمة هذا يمكن إما أن يكون شراء أو بيع، وسوف تتوافق إما افتراضية شراء أو بيع الصفقات. إذا كانت قيمة هذا هو شراء، ثم عند توليد المخرجات وسوف ننظر فقط في النجاح المحتمل من الصفقات شراء افتراضية. بدلا من ذلك، إذا كانت قيمة هذا هو بيع، ثم عند توليد المخرجات وسوف ننظر فقط في النجاح المحتمل من الصفقات بيع افتراضية.


القيم التالية المستخدمة هي وقف الخسارة وجني الأرباح لهذه الصفقات الافتراضية. يتم تعيين القيم في نقاط، وسوف تحدد مستويات الحد والحد من كل من الصفقات الافتراضية.


المعلمة النهائية هي مدة التداول. ويقاس هذا المتغير بالساعات وسيضمن أن الصفقات الوحيدة التي تكتمل خلال هذه المدة القصوى ستعتبر ناجحة. والسبب في إدراج هذا المتغير هو تجنب حركة إشارات ناقلات الدعم في سوق جانبية بطيئة الحركة.


اعتبارات لجعل عند اختيار المدخلات.


من المهم وضع بعض الفكر في اختيار المدخلات عند تنفيذ آلات ناقلات الدعم في التداول الخاص بك. على غرار المثال سنيك، من المهم اختيار المدخلات التي من المتوقع أن يكون لها نفس الاختلافات عبر الاختلاف. على سبيل المثال، قد تميل إلى استخدام المتوسط ​​المتحرك كمدخل، ولكن بما أن متوسط ​​السعر على المدى الطويل يميل إلى التغير بشكل كبير مع مرور الوقت، فإن المتوسط ​​المتحرك في العزلة قد لا يكون أفضل مدخلات للاستخدام. ويرجع ذلك إلى أنه لن يكون هناك أي تشابه كبير بين متوسط ​​المتوسط ​​المتحرك اليوم ومتوسط ​​المتوسط ​​المتحرك قبل ستة أشهر.


افترض أننا نقوم بتداول اليورو مقابل الدولار الأميركي واستخدام آلة ناقلات الدعم مع متوسط ​​الدخل المتحرك لإشارة الصفقات "شراء". ويقول السعر الحالي هو 1.10، ومع ذلك فإنه يولد بيانات التدريب من قبل ستة أشهر عندما كان السعر 0.55. عند تدريب جهاز ناقل الحركة، فإن النمط الذي يعثر عليه قد يؤدي فقط إلى إشارة تجارية عندما يكون السعر حوالي 0.55، حيث أن هذه هي البيانات الوحيدة التي يعرفها. لذلك، قد لا يشير جهاز ناقل الدعم الخاص بك إلى أي تداول حتى ينخفض ​​السعر مرة أخرى إلى 0.55.


وبدلا من ذلك، يمكن أن تكون المدخلات الأفضل لاستخدامها في آلة ناقلات الدعم ماسد أو مذبذب مشابه لأن قيمة ماسد مستقلة عن متوسط ​​مستوى السعر ولا تشير إلا إلى حركة نسبية. أوصي بتجربة هذا الأمر لمعرفة ما ينتج أفضل النتائج لك.


ومن الاعتبارات الأخرى التي يجب اتخاذها عند اختيار المدخلات التأكد من أن آلة ناقل الدعم لديها لقطة كافية لمؤشر للإشارة إلى تجارة جديدة. قد تجد في تجربة التداول الخاصة بك أن ماسد مفيد فقط عندما يكون لديك القضبان الخمسة الماضية للنظر في، وهذا سوف تظهر اتجاها. قد يكون شريط واحد من ماسد عديم الفائدة في عزلة إلا إذا كنت تستطيع معرفة ما إذا كان يتجه صعودا أو هبوطا. لذلك، قد يكون من الضروري لتمرير الحانات القليلة الماضية من مؤشر الماكد إلى جهاز ناقل الدعم. هناك طريقتان ممكنتان يمكنك القيام بهما:


يمكنك إنشاء مؤشر مخصص جديد يستخدم الحانات الخمسة الماضية لمؤشر ماسد لحساب الاتجاه كقيمة واحدة. ويمكن بعد ذلك تمرير هذا المؤشر المخصص إلى جهاز متجه الدعم كإدخال واحد، أو.


يمكنك استخدام القضبان الخمسة السابقة لمؤشر ماسد في جهاز ناقل الدعم كخمسة مدخلات منفصلة. والطريقة للقيام بذلك هي تهيئة خمس حالات مختلفة لمؤشر ماسد. يمكن تهيئة كل من المؤشرات بتخالف مختلف عن الشريط الحالي. ثم يمكن تمرير خمسة مقابض من مؤشرات منفصلة إلى آلة ناقلات الدعم. وتجدر الإشارة إلى أن الخيار 2 سوف يؤدي إلى إطالة أمد تنفيذ المستشار الخبير الخاص بك. لمزيد من المدخلات لديك، ويعد سوف يستغرق لتدريب بنجاح.


تنفيذ دعم ناقلات الآلات في والخبير مستشار.


لقد أعدت مستشار الخبراء الذي هو مثال على كيف يمكن لشخص ما استخدام آلات ناقلات الدعم في التداول الخاصة بهم (نسخة من هذا يمكن تحميلها عن طريق اتباع هذا الرابط هتبس: // mql5 / إن / كود / 1229). نأمل أن مستشار الخبراء تسمح لك لتجربة قليلا مع آلات ناقلات الدعم. أوصي لك نسخ / تغيير / تعديل مستشار الخبراء لتناسب أسلوب التداول الخاصة بك. وتعمل وحدة التقييم على النحو التالي:


يتم إنشاء اثنين من آلات ناقلات الدعم الجديدة باستخدام مكتبة سفماشينيتول. يتم إعداد واحد للإشارة إلى صفقات جديدة "شراء" ويتم تعيين الآخر يصل إلى إشارة جديدة "بيع" الصفقات.


يتم تهيئة سبعة مؤشرات قياسية مع كل من مقابضها المخزنة على مجموعة صحيحة (ملاحظة: أي مجموعة من المؤشرات يمكن استخدامها كمدخلات، فإنها تحتاج فقط إلى أن يتم تمريرها إلى سفم في مجموعة واحدة صحيح).


يتم تمرير صفيف مقابض المؤشرات إلى أجهزة ناقل الدعم الجديدة.


باستخدام مجموعة من مقابض المؤشر وغيرها من المعالم، وتستخدم بيانات الأسعار التاريخية لتوليد المدخلات والمخرجات دقيقة لاستخدامها لتدريب آلات ناقلات الدعم.


وبمجرد أن يتم توليد جميع المدخلات والمخرجات، يتم تدريب كل من آلات ناقلات الدعم.


يتم استخدام آلات ناقلات الدعم المدربة في إي للإشارة إلى صفقات "شراء" و "بيع" جديدة. عندما يتم الإشارة إلى تجارة جديدة أو "بيع"، يتم فتح الصفقة جنبا إلى جنب مع أوامر وقف الخسارة وجني الأرباح اليدوية.


يتم تنفيذ التهيئة والتدريب للجهاز ناقلات الدعم ضمن الدالة أونينيت (). للرجوع اليها، تم تضمين هذا الجزء من إي سفترادر ​​أدناه مع الملاحظات.


دعم متقدم تجارة آلة المتجهات.


وقد بنيت قدرة إضافية في أداة دعم ناقلات الدعم أداة للمستخدمين أكثر تقدما هناك. تسمح الأداة للمستخدمين بالمرور في بيانات الإدخال المخصصة الخاصة بهم وبيانات الإخراج (كما في المثال سنيك). هذا يسمح لك لتصميم مخصص المعايير الخاصة بك لدعم ناقلات ناقلات المدخلات والمخرجات، وتمرير يدويا في هذه البيانات لتدريب عليه. هذا يفتح الفرصة لاستخدام آلات ناقلات الدعم في أي جانب من جوانب التداول الخاص بك.


ليس من الممكن فقط استخدام آلات ناقلات الدعم للإشارة إلى الصفقات الجديدة، ولكن يمكن أن تستخدم أيضا للإشارة إلى إغلاق الصفقات وإدارة الأموال والمؤشرات المتقدمة الجديدة وما إلى ذلك لضمان عدم تلقي أخطاء، فمن المهم أن فهم كيفية تنظيم هذه المدخلات والمخرجات.


المدخلات: يتم تمرير المدخلات إلى سفم كمصفوفة الأبعاد 1 من القيم المزدوجة. يرجى ملاحظة أنه يجب أن يتم تمرير أي مدخل تقوم بإنشائه كقيمة مزدوجة. يجب تحويل كل منطقي، صحيح، وما إلى ذلك إلى قيمة مزدوجة قبل أن يتم تمريرها إلى جهاز ناقل الدعم. والمدخلات مطلوبة بالشكل التالي. على سبيل المثال، نفترض أننا تمر في المدخلات مع 3 المدخلات × 5 نقاط التدريب. لتحقيق ذلك، يجب أن يكون لدينا مجموعة مزدوجة 15 وحدة طويلة في شكل:


| A 1 | B 1 | C 1 | A 2 | B 2 | C 2 | A 3 | B 3 | C 3 | A 4 | B 4 | C 4 | A 5 | B 5 | C 5 |


ومن الضروري أيضا تمرير قيمة لعدد المدخلات. في هذه الحالة، N_Inputs = 3.


المخرجات: يتم تمرير المخرجات في مجموعة من القيم المنطقية. هذه القيم المنطقية هي الناتج المطلوب من سفم تتوافق مع كل مجموعة من المدخلات التي تم تمريرها. بعد المثال أعلاه، ويقول لدينا 5 نقاط التدريب. في هذا السيناريو، سوف تمر في صفيف منطقي من قيم الإخراج الذي هو 5 وحدات طويلة.


عند توليد المدخلات والمخرجات الخاصة بك، تأكد من أن طول المصفوفات يطابق القيم التي تمر بها. إذا لم تتطابق، سيتم إنشاء خطأ إعلامك من التناقض. على سبيل المثال، إذا مررنا في N_Inputs = 3، والمدخلات عبارة عن صفيف طول 16، سيتم طرح خطأ (حيث أن قيمة N_inputs من 3 تعني أن طول أي صفيف دخل يجب أن يكون مضاعفا 3). وبالمثل، تأكد من أن عدد مجموعات المدخلات وعدد النواتج التي تمر بها متساوية. مرة أخرى، إذا كان لديك N_Inputs = 3، طول المدخلات من 15 وطول النواتج من 6، سيتم طرح خطأ آخر (كما لديك 5 مجموعات من المدخلات و 6 النواتج).


حاول التأكد من وجود اختلاف كاف في مخرجات التدريب. على سبيل المثال، إذا كنت تمر في 100 نقطة التدريب، وهو ما يعني مجموعة من المخرجات من طول 100، وجميع القيم خاطئة مع صحيح واحد فقط، ثم التفريق بين الحالة الحقيقية والحالة الزائفة ليست كافية بما فيه الكفاية. وهذا سوف يؤدي إلى التدريب سفم سريع جدا، ولكن الحل النهائي يجري سيئة للغاية. مجموعة التدريب أكثر تنوعا وغالبا ما يؤدي إلى سفم أكثر عاطفية.


Quintuitive.


وجهات نظر بديهية كميا على الأسواق.


التداول مع دعم آلات المتجهات (سفم)


وأخيرا جميع النجوم قد الانحياز وأستطيع أن تكرس بثقة بعض الوقت للاختبار الخلفي من أنظمة التداول الجديدة، ودعم آلات ناقلات (سفم) هي جديدة & # 8220؛ لعبة & # 8221؛ والتي سوف تبقى لي مشغول لفترة من الوقت.


سفمس هي أداة معروفة من مجال آلة التعلم تحت إشراف، وتستخدم كل من التصنيف والانحدار. لمزيد من التفاصيل راجع الأدب.


يبدو لي أن التطبيق الأكثر بديهية للتداول هو الانحدار، لذلك دعونا & # 8217؛ ق عن طريق بناء نموذج الانحدار سفم.


بعد تجربتنا مع نماذج أرما + غارتش، سنبدأ بمحاولة التنبؤ بالعائدات، بدلا من الأسعار. وبالمثل، في اختباراتنا الأولى، سوف نستخدم فقط عوائد الأيام الخمسة السابقة كميزات تحدد عودة يوم معين. سنبدأ مع التاريخ من 500 يوما كما مجموعة التدريب.


في مصطلحات رياضية أكثر، لمجموعة التدريب لدينا ميزات N، لكل واحد منهم لدينا عينات M. لدينا أيضا ردود M.


نظرا لصف من قيم الميزة، المصفوفة اليسرى، يتم تدريب سفم لإنتاج قيمة الاستجابة. في مثالنا المحدد، لدينا خمسة أعمدة (ميزات)، كل عمود مناظرة للعائدات بفارق زمني مختلف (من 1 إلى 5). لدينا 500 عينات و الردود المقابلة.


مرة واحدة يتم تدريب سفم على هذه المجموعة، يمكننا البدء في تغذية مع مجموعات من خمس ميزات، المقابلة للعائدات للأيام الخمسة السابقة، وسوف سفم توفر لنا مع الاستجابة، وهو العائد المتوقع. على سبيل المثال، بعد تدريب سفم على ال 500 يوم السابقة، سوف نستخدم العوائد للأيام 500، 499، 498، 497 و 496 (هذه هي لنا كمدخل للحصول على العائد المتوقع ليوم 501.


من جميع الحزم المتوفرة في R، قررت أن تختار حزمة e1071. وكان الخيار الثاني قريب حزمة كيرنلاب، التي ما زلت تخطط لمحاولة في المستقبل.


ثم حاولت بعض الاستراتيجيات. أولا حاولت شيئا مشابها جدا لنهج أرما + غارتش & # 8211؛ أي العائدات المتخلفة عن الأيام الخمسة السابقة. لقد فوجئت تماما لرؤية هذه الاستراتيجية أداء أفضل من أرما + غارتش (وهذا هو أرض الوطن من أرما + غارتش، وكنت قد سعيدة جدا فقط مع أداء مماثل)!


بعد ذلك، حاولت نفس الميزات الخمس، ولكن في محاولة لتحديد أفضل مجموعة فرعية. تم اختيار باستخدام نهج الجشع، بدءا من 0 الميزات، وإضافة تفاعلي الميزة التي تقلل من الخطأ أفضل. وقد أدى هذا النهج إلى تحسين الأمور.


وأخيرا، حاولت نهجا مختلفا مع حوالي عشرة الميزات. وشملت الميزات عوائد على مدى فترة مختلفة من الزمن (يوم واحد، يومين، 5 أيام، الخ)، وبعض الإحصاءات (متوسط، وسيط، سد، الخ) والحجم. لقد استخدمت نفس النهج الجشع لتحديد الميزات. هذا النظام النهائي أظهر أداء جيدا جدا أيضا، ولكن أخذ الجحيم من الوقت لتشغيل.


الوقت لإنهاء هذه المشاركة، نتائج الاختبار الخلفي يجب أن تنتظر. حتى ذلك الحين يمكنك أن تلعب مع شفرة المصدر الكامل نفسك. في ما يلي مثال لاستخدامه:


مرحبا، هل من الممكن أن يكون مثالا للتطبيق إذا وظيفتك؟


تم تحديث المشاركة.


مشاركة رائعة حول سفم & # 8217؛ s. شكرا للمشاركة. أنا & # 8217؛ م R مبتدئ، هل يمكن أن تخبرني ما هو الفرق بين القيام بذلك.


في ويندوز دوسن & # 8217؛ ر العمل بسبب مشكلة متعددة النوى.


شيء آخر لا أفهمه ينعكس في هذا إلى صفوف من التعليمات البرمجية.


في رأيي أنه أكثر فعالية لدمج السلسلة.


وأن يكون هناك حجة واحدة فقط = كائن لتشغيل الدالة بدلا من 2.


العمل المثير للاهتمام، وذلك بفضل.


أرغ، ويندوز & # 8211؛ أنا استخدامه نادرا في الآونة الأخيرة. فوجئت تماما لا يزال، منذ حزمة موازية هي جزء من توزيع قاعدة R الآن. نأمل أنه سيتم تناولها قريبا.


وفي الوقت نفسه، ماذا عن عدم استخدام التنفيذ المتوازي؟ أيضا هناك حزم أخرى توفر التنفيذ المتوازي، ولكن هذا سيكون المزيد من العمل.


أنت على حق بشأن الدمج & # 8211؛ ما زلت أتساءل لماذا فعلت ذلك بهذه الطريقة هذه المرة. :)


I & # 8217؛ m تلقي أخطاء.


الآن الخطأ هو.


وGT. داتا = سفمفاتوريس (ت) [، c (1،2)]


خطأ في match. fun (فان): أوبجيكت & # 8216؛ سكيونيس & # 8217؛ غير معثور عليه.


ولكن عندما أقدم يدويا كائن البيانات أتلقى خطأ في التنبؤ.


سفمكومبوتونيفوريكاست & لوت؛ - وظيفة تتعلق الأبعاد و.


من الصعب علي التصحيح.


الانحراف يأتي من حزمة بيرفورمانساناليتيكش، التي تحتاج إلى تثبيت من كران. إضافة تتطلب (بيرفورمانساناليتيكش) كما السطر الأول من سفمفاتوريس يجب أن تعالج المشكلة الأولى.


خطأ في merge. xts (ريس، شتس (n. trim (لاغ (رولمان (ريتس، ​​k = 21، ألين = & # 8220؛ رايت & # 8221؛)،:


طول & # 8216؛ ديمنامس & # 8217؛ [2] لا يساوي مدى الصفيف.


يبدو أنه في رمز ويندوز يحتاج إلى الكثير من التغييرات.


Mike, I never meant the code to be used directly (until now I was providing only snippets), but I am surprised that R on Windows is so ugly. Not sure what’s your goal, but to analyze the strategies performance, you can use the indicator series which are already computed.


It’s just pure academic interest on SVM. I used to work with clusters, PCA and I am curious how SVM is doing the same work.


In windows a lot of error are related to objects with dates as xts is or data frames.


UNIX is better but all brokers give API for windows. Some of them in Java and only this we may use from UNIX.


I don’t like win architecture but it’s a habit already and I don’t have time to change OS.


I just tried it on windows 7, 64 bit, R version 2.15.2. I get a warning from svmFeatures, which I know how to fix (calling sd on an xts/zoo object does interesting conversion to a matrix), but no problems. Running:


One question if you don’t mind.


Why are you using get with function cetSymbols from quantmod package?


I use call vers.


SPY <- getSymbols('SPY', auto. assign = FALSE)


You have a lot to compute and get consume memory and takes time to obtain objects name.


as a string var.


But I’m surprised with this result before call.


1 function (…, list = character(), package = NULL, lib. loc = NULL,


2 verbose = getOption(“verbose”), envir =.GlobalEnv)


4 fileExt <- function(x)


It seems that data is reserved word.


And now I don't know what is going to features function.


I am using R 2.15.2 on 64-bit linux. On my system data is also a function, but I don’t think this is the problem.


That’s probably a better way. Have seen it before, but didn’t pay attention till now to realize that it does exactly that. شكر.


What do you mean when you speak about the lagged returns? IS it the value 500,499,498,497,496 for the prediction of the return 501?


Yes, these returns are used to forecast the return of 501, which is used as the position (long/short depending on the sign) for 501. The model is trained on the previous data only, i. e. the last “row” in the training set is 499,498,497,496,495.


Ok, that’s sound good, and for the return do you use this formule :


return t=log(Price t+1/Price t)


And after you normalize (center and scale ) the return?


You can find these details in the accompanied source code. I use the discrete returns:


I don’t don’t center the data, neither I scale it. However, both packages which I use (caret+kernlab and e1071) seem to do that by default.


Another things, sorry, but you build your model on the previous 499 values, this is your training data set,


And afte, r to forecast the 501 return you use the last row as test values?


Why build a model on the 500 values and use the last row i. e 500,499 etc another time to test or to train?


in your tutorial you said: For example, after training the SVM on the previous 500 days, we will use the returns for days 500, 499, 498, 497 and 496 (these are ours as the input to obtain the forecasted return for day 501.


And in your response you said:Yes, these returns are used to forecast the return of 501, which is used as the position (long/short depending on the sign) for 501. The model is trained on the previous data only, i. e. the last “row” in the training set is 499,498,497,496,495.


Are you ok if i claim, i build the model on the 500 values, and to forecasted the 501 i use the model build previously and give him to “eat” the last row of the training dataset ie:500,499etc as input to obtain the forecasted 501’s value?


Regards and sorry for the multiple post, but i have got trouble with my network.


In general, I think it should be ok to use the approach you are suggesting. Notice that this approach will be much more demanding to implement in real-life trading, or at least the way I do it.


If one is to compute all reasonable closing prices in advance, the new approach will need to do one fit for each individual close and one predict. Compare to the other approach – the model is fit based on the previous 500 days, then only the new data (different for each close) is being fed. In other words, here we have one fit, many predicts.


Really admire your work mate, Im new to SVM with R, Im trying to use ten technical indictors to forecast stock index tommorrow’s movements(up or down as 1 or -1), when you train the model, what would you use as response column…if you are at 07/07/2018…you use that day movement or 08/07’s movement for 07/07’s technical indicators…if you use 07/07’s input…how do you forcast tommorrow’s results as you dont know tommorrow’s inputs…I hope that makes sense…


any help would be appreciated.


Hi Louis, if the target is only long/short, you may want to use classification instead of regression. Most packages silently switch to classification if the response vector is “factors” rather than numericals. Check quantumfinancier. wordpress/2018/06/26/support-vector-machine-rsi-system/ for an example.


Before starting the step forward process, I align the desired response with the data that predicts it. In general, this is a lag(1) of the predictors (data). This aligns the desired value of 08/07 (the return of 08/07) with its predictors (the indicators as of 07/07 close). Then I fit the model using the data by excluding the last date. In other words, let’s say I am about to predict 08/07. The last date I look when fitting is 07/07. Since the data is already lagged, the last date for the indicators is in fact 06/07. Finally to forecast one day ahead, I feed the data for 08/07, which corresponds to the indicators on 07/07. Now I can compare the predicted with the real value. This can relatively-easily be applied in practice, as long as the indicators are based on closing prices only. Anything using high/low/volume/etc (stochastics for instance), needs to either be lagged by an extra day, or the trading cannot happen right at the close … see my other post: quintuitive/2018/08/23/trading-at-the-close-the-mechanics/.


أتمنى أن يساعدك هذا.


Thats really helpful, thanks a lot mate…


most papers about SVM online are quite pointless…I guess not everyone likes to share their secrets haha.


sorry, one more question: for the model with the best performance, what inputs did you use to forecast tommorrow’s return..


AS quote”Finally, I tried a different approach with about a dozen features. The features included returns over different period of time (1-day, 2-day, 5-day, etc), some statistics (mean, median, sd, etc) and volume. I used the same greedy approach to select features. This final system showed a very good performance as well, but it took a hell of a time to run.”


The model with the best performance, by just a bit, was using lagged (by 1,2,3,4 and 5 days) daily returns. The only twist was that it was using a greedy method to select the “best” combination of features.


I just finished my work, I adopted a classification approach to predict tommorrow’s movement…


the accuracy is almost 86% on a 140days testdate.. I wonder if this is a little bit too high…


Nevertheless…Thank you so much.


Sounds too high to me. I’d certainly review it a few more times before taking it seriously – that’s like having a crystal ball.;)


Here is an idea, when you select the training set, try to divede your training set into two equal parts, one is the response returns above the average, the other is the returns below the average…this way, your forecast accuracy might not change much, but you can forecast the BIG movements much more accurate…


the performance should be improved…I’ve tried this and the results are quite nice…please let me know if this works for you..cheers.


My names is Krzysztof and I’m an author of this thread.


In this project I was using different machine learning algorithms (including SVM) trying to predict if certain trade with fixed TP/SL will be successful or not so classification.


Some comments/questions to your code.


1)Using cross validation (tune. control, cross=cross). Are you sure that using cross validation is correct in case of time series ?? In such case training will be done on past data and by definition of time series it introduce future leak and inflated results. Perhaps fix option should be used instead.


2)Kernel constants. The most important parameters for SVM are kernel constants. Why those fixed values are used and not another ??


3)Sample size/Choice of SVM. The training time of this SVM is exponentially correlated to the training sample size as far as I remember. But there are other SVMs specialized for use with bigger training sample size e. g. I was training my system on up to 150 000 bars within few hours. For example pegassos, libocas or SVMLight. In such case it is possible e. g. to use hourly data and bigger sample size which will give much better accuracy.


4) Why not use RWeka package and have the access perhaps more than hundred ML algos.


Quite an interesting thread, certainly something to take a look at – thanks for bringing it up. What do you mean by “TP/SL”?


1) The code is mostly for illustration purposes, and I didn’t find it very useful overall. I agree, it is dubious to consider each row in the training set as independent from the rest in the case of time series with their correlations, but it is an approach. According to robjhyndman/hyndsight/crossvalidation/, a better approach might be a one-step cross-validation using the past data, which should be relatively easy to add.


2) Nothing special about these kernel constants – just a set to iterate through. I think I used values found in examples using the package(s). The optimization chooses the best.


3) Good to know. Currently I don’t trade intraday, so I never had the need to deal with such big amounts of data. For daily data, increasing the window improves the performance, but up to a point from my experience. A bit counter intuitive that longer time window will improve the forecasts indefinitely - at some point the data is too much (as a ratio vs the number of parameters optimized).


4) Haven’t really looked into RWeka. Originally I started with e1071 because it’s fast and very stable. Then I switched to caret, which provides unified interface to many other packages, including some algorithms from RWeka. In my experience, I haven’t found an ML approach that really stands out for prediction of time series data. Have you?


Thanks for sharing,


1)Using cross validation (tune. control, cross=cross). Are you sure that using cross validation is correct in case of time series ?? In such case training will be done on past data and by definition of time series it introduce future leak and inflated results. Perhaps fix option should be used instead.


should be ‘In such case training will be done on future data’


My implementation doesn’t (at least by design;)) use future data. If the history is 500 points, the cross validation is used within these 500 to determine the best fit.


TP/SL – take profit/ stop loss. System was trying to trade on every bar (buy or sell) than label.


was determined (trade successful/unsuccessful) depends if TP or SL was hit first.


“If the history is 500 points, the cross validation is used within these 500 to determine the best fit”


Well in such case in sample results will be inflated and has no meaning. For example if you divide training period for 10 sub periods and train on periods 1-8 and 10 than evaluate on period 9, future leak occurs as period 10 is after period 9 so in the future.


this how cross validation works i think and it is applicable only for static patterns. Only walk forward has a meaning in case of time series.


When i try the code i find the ROC 2 for the row 29/03/195: Is the difference of : value of 28/03 and 24/03 divide by value of 24/03, why is not the value of 27/03- value of 24/03 divide by value of 24/03….


The code is just for illustration. You can modify it anyway you want and use whatever features you think may improve the predictions. The ROC function comes from the TTR package.


Is it possible to have a plot of the ARMA model and SVM out-of-sample to compare their performance?


Not likely to get the time to go back to it, but will keep it in mind.


Trading with SVMs: Performance.


To get a feeling of SVM performance in trading, I run different setups on the S&P 500 historical data from … the 50s. The main motif behind using this decade was to decide what parameters to vary and what to keep steady prior to running the most important tests. Treat it as an “in-sample” test to avoid (further;)) over-fitting. First the performance chart:


S&P 500 Trading Performance.


Very nice! Using the 5 lagged daily returns shows similar performance to the ARMA+GARCH strategy, which I found very promising. If you wonder why I am so excited about this fact, it’s because here we are in the area where ARMA+GARCH is best, and yet, SVMs show comparable performance.


The statistics are also impressive:


While writing this post, I found another effort to use SVMs in trading by Quantum Financier. His approach uses RSI of different length as input to the SVM, but it also uses classification (maps the returns to two values, short or long) instead of regression. Since I was planning to try classification anyways, his post inspired me to implement it and run an additional comparison, regression vs classification:


S&P 500 SVM Trading – Regression vs Classification.


What can I say – they both seem to work perfectly. As a reader suggested in the comments, the Classification does exhibit more consistent returns.


Looking at the table, the classification cut in half the maximum drawdown, but interestingly, it didn’t improve the Sharpe ratio significantly. Nothing conclusive here though, it was a quick run of the fastest (in terms of running time) strategies.


There is still a long list of topics to explore, just to give you an idea, in no particular order:


Add other features. Mostly thinking of adding some Fed-related series, this data goes back to 1960, so it’s coming soon.:) Try other svm parameters: other regressions, other classifications, other kerenls, etc. This is more like a stability test. Try other error functions. The default is to use the mean square error, but in the case of regression, why not use Sharpe Ratio (in-sample)? The regression case is simpler, since we have the actual returns – check the input of tune. control . Try longer periods instead of days. Weekly is a start, but ideally I’d like to implement two or three day periods. Vary the loopback period. Use more classes with classification: large days, medium days, etc.


This will take time. As always, feedback and comments are welcome.


Better Strategies 4: Machine Learning.


Deep Blue was the first computer that won a chess world championship. That was 1996, and it took 20 years until another program, AlphaGo , could defeat the best human Go player. Deep Blue was a model based system with hardwired chess rules. AlphaGo is a data-mining system, a deep neural network trained with thousands of Go games. Not improved hardware, but a breakthrough in software was essential for the step from beating top Chess players to beating top Go players.


In this 4th part of the mini-series we’ll look into the data mining approach for developing trading strategies. This method does not care about market mechanisms. It just scans price curves or other data sources for predictive patterns. Machine learning or “Artificial Intelligence” is not always involved in data-mining strategies. In fact the most popular – and surprisingly profitable – data mining method works without any fancy neural networks or support vector machines.


Machine learning principles.


A learning algorithm is fed with data samples , normally derived in some way from historical prices. Each sample consists of n variables x 1 .. x n , commonly named predictors , features , signals , or simply input . These predictors can be the price returns of the last n bars, or a collection of classical indicators, or any other imaginable functions of the price curve (I’ve even seen the pixels of a price chart image used as predictors for a neural network!). Each sample also normally includes a target variable y , like the return of the next trade after taking the sample, or the next price movement. In the literature you can find y also named label or objective . In a training process , the algorithm learns to predict the target y from the predictors x 1 .. x n . The learned ‘memory’ is stored in a data structure named model that is specific to the algorithm (not to be confused with a financial model for model based strategies!). A machine learning model can be a function with prediction rules in C code, generated by the training process. Or it can be a set of connection weights of a neural network.


The predictors, features, or whatever you call them, must carry information sufficient to predict the target y with some accuracy. They m ust also often fulfill two formal requirements. First, all predictor values should be in the same range, like -1 .. +1 (for most R algorithms) or -100 .. +100 (for Zorro or TSSB algorithms). So you need to normalize them in some way before sending them to the machine. Second, the samples should be balanced , i. e. equally distributed over all values of the target variable. So there should be about as many winning as losing samples. If you do not observe these two requirements, you’ll wonder why you’re getting bad results from the machine learning algorithm.


Regression algorithms predict a numeric value, like the magnitude and sign of the next price move. Classification algorithms predict a qualitative sample class, for instance whether it’s preceding a win or a loss. Some algorithms, such as neural networks, decision trees, or support vector machines, can be run in both modes.


A few algorithms learn to divide samples into classes without needing any target y . That’s unsupervised learning , as opposed to supervised learning using a target. Somewhere inbetween is reinforcement learning , where the system trains itself by running simulations with the given features, and using the outcome as training target. AlphaZero, the successor of AlphaGo, used reinforcement learning by playing millions of Go games against itself. In finance there are few applications for unsupervised or reinforcement learning. 99% of machine learning strategies use supervised learning.


Whatever signals we’re using for predictors in finance, they will most likely contain much noise and little information, and will be nonstationary on top of it. Therefore financial prediction is one of the hardest tasks in machine learning. More complex algorithms do not necessarily achieve better results. The selection of the predictors is critical to the success. It is no good idea to use lots of predictors, since this simply causes overfitting and failure in out of sample operation. Therefore data mining strategies often apply a preselection algorithm that determines a small number of predictors out of a pool of many. The preselection can be based on correlation between predictors, on significance, on information content, or simply on prediction success with a test set. Practical experiments with feature selection can be found in a recent article on the Robot Wealth blog.


Here’s a list of the most popular data mining methods used in finance.


1. Indicator soup.


Most trading systems we’re programming for clients are not based on a financial model. The client just wanted trade signals from certain technical indicators, filtered with other technical indicators in combination with more technical indicators. When asked how this hodgepodge of indicators could be a profitable strategy, he normally answered: “Trust me. I’m trading it manually, and it works.”


It did indeed. At least sometimes. Although most of those systems did not pass a WFA test (and some not even a simple backtest), a surprisingly large number did. And those were also often profitable in real trading. The client had systematically experimented with technical indicators until he found a combination that worked in live trading with certain assets. This way of trial-and-error technical analysis is a classical data mining approach, just executed by a human and not by a machine. I can not really recommend this method – and a lot of luck, not to speak of money, is probably involved – but I can testify that it sometimes leads to profitable systems.


2. Candle patterns.


Not to be confused with those Japanese Candle Patterns that had their best-before date long, long ago. The modern equivalent is price action trading . You’re still looking at the open, high, low, and close of candles. You’re still hoping to find a pattern that predicts a price direction. But you’re now data mining contemporary price curves for collecting those patterns. There are software packages for that purpose. They search for patterns that are profitable by some user-defined criterion, and use them to build a specific pattern detection function. It could look like this one (from Zorro’s pattern analyzer):


This C function returns 1 when the signals match one of the patterns, otherwise 0. You can see from the lengthy code that this is not the fastest way to detect patterns. A better method, used by Zorro when the detection function needs not be exported, is sorting the signals by their magnitude and checking the sort order. An example of such a system can be found here.


Can price action trading really work? Just like the indicator soup, it’s not based on any rational financial model. One can at best imagine that sequences of price movements cause market participants to react in a certain way, this way establishing a temporary predictive pattern. However the number of patterns is quite limited when you only look at sequences of a few adjacent candles. The next step is comparing candles that are not adjacent, but arbitrarily selected within a longer time period. This way you’re getting an almost unlimited number of patterns – but at the cost of finally leaving the realm of the rational. It is hard to imagine how a price move can be predicted by some candle patterns from weeks ago.


Still, a lot effort is going into that. A fellow blogger, Daniel Fernandez, runs a subscription website (Asirikuy) specialized on data mining candle patterns. He refined pattern trading down to the smallest details, and if anyone would ever achieve any profit this way, it would be him. But to his subscribers’ disappointment, trading his patterns live (QuriQuant) produced very different results than his wonderful backtests. If profitable price action systems really exist, apparently no one has found them yet.


3. Linear regression.


The simple basis of many complex machine learning algorithms: Predict the target variable y by a linear combination of the predictors x 1 .. x n .


The coefficients a n are the model. They are calculated for minimizing the sum of squared differences between the true y values from the training samples and their predicted y from the above formula:


For normal distributed samples, the minimizing is possible with some matrix arithmetic, so no iterations are required. In the case n = 1 – with only one predictor variable x – the regression formula is reduced to.


which is simple linear regression , as opposed to multivariate linear regression where n > 1 - Simple linear regression is available in most trading platforms, f. i. with the LinReg indicator in the TA-Lib. With y = price and x = time it’s often used as an alternative to a moving average. Multivariate linear regression is available in the R platform through the lm(..) function that comes with the standard installation. A variant is polynomial regression . Like simple regression it uses only one predictor variable x , but also its square and higher degrees, so that x n == x n :


With n = 2 or n = 3 , polynomial regression is often used to predict the next average price from the smoothed prices of the last bars. The polyfit function of MatLab, R, Zorro, and many other platforms can be used for polynomial regression.


4. Perceptron.


Often referred to as a neural network with only one neuron. In fact a perceptron is a regression function like above, but with a binary result, thus called logistic regression . It’s not regression though, it’s a classification algorithm. Zorro’s advise(PERCEPTRON, …) function generates C code that returns either 100 or -100, dependent on whether the predicted result is above a threshold or not:


You can see that the sig array is equivalent to the features x n in the regression formula, and the numeric factors are the coefficients a n .


5. N eural networks.


Linear or logistic regression can only solve linear problems. Many do not fall into this category – a famous example is predicting the output of a simple XOR function. And most likely also predicting prices or trade returns. An artificial neural network (ANN) can tackle nonlinear problems. It’s a bunch of perceptrons that are connected together in an array of layers . Any perceptron is a neuron of the net. Its output goes to the inputs of all neurons of the next layer, like this:


Like the perceptron, a neural network also learns by determining the coefficients that minimize the error between sample prediction and sample target. But this requires now an approximation process, normally with backpropagating the error from the output to the inputs, optimizing the weights on its way. This process imposes two restrictions. First, the neuron outputs must now be continuously differentiable functions instead of the simple perceptron threshold. Second, the network must not be too deep – it must not have too many ‘hidden layers’ of neurons between inputs and output. This second restriction limits the complexity of problems that a standard neural network can solve.


When using a neural network for predicting trades, you have a lot of parameters with which you can play around and, if you’re not careful, produce a lot of selection bias :


Number of hidden layers Number of neurons per hidden layer Number of backpropagation cycles, named epochs Learning rate, the step width of an epoch Momentum, an inertia factor for the weights adaption Activation function.


The activation function emulates the perceptron threshold. For the backpropagation you need a continuously differentiable function that generates a ‘soft’ step at a certain x value. Normally a sigmoid , tanh , or softmax function is used. Sometimes it’s also a linear function that just returns the weighted sum of all inputs. In this case the network can be used for regression, for predicting a numeric value instead of a binary outcome.


Neural networks are available in the standard R installation ( nnet , a single hidden layer network) and in many packages, for instance RSNNS and FCNN4R .


6. Deep learning.


Deep learning methods use neural networks with many hidden layers and thousands of neurons, which could not be effectively trained anymore by conventional backpropagation. Several methods became popular in the last years for training such huge networks. They usually pre-train the hidden neuron layers for achieving a more effective learning process. A Restricted Boltzmann Machine ( RBM ) is an unsupervised classification algorithm with a special network structure that has no connections between the hidden neurons. A Sparse Autoencoder ( SAE ) uses a conventional network structure, but pre-trains the hidden layers in a clever way by reproducing the input signals on the layer outputs with as few active connections as possible. Those methods allow very complex networks for tackling very complex learning tasks. Such as beating the world’s best human Go player.


Deep learning networks are available in the deepnet and darch R packages. Deepnet provides an autoencoder, Darch a restricted Boltzmann machine. I have not yet experimented with Darch, but here’s an example R script using the Deepnet autoencoder with 3 hidden layers for trade signals through Zorro’s neural() function:


7. Support vector machines.


Like a neural network, a support vector machine (SVM) is another extension of linear regression. When we look at the regression formula again,


we can interpret the features x n as coordinates of a n - dimensional feature space . Setting the target variable y to a fixed value determines a plane in that space, called a hyperplane since it has more than two (in fact, n-1 ) dimensions. The hyperplane separates the samples with y > o from the samples with y < 0. The a n coefficients can be calculated in a way that the distances of the plane to the nearest samples – which are called the ‘support vectors’ of the plane, hence the algorithm name – is maximum. This way we have a binary classifier with optimal separation of winning and losing samples.


The problem: normally those samples are not linearly separable – they are scattered around irregularly in the feature space. No flat plane can be squeezed between winners and losers. If it could, we had simpler methods to calculate that plane, f. i. linear discriminant analysis . But for the common case we need the SVM trick: Adding more dimensions to the feature space. For this the SVM algorithm produces more features with a kernel function that combines any two existing predictors to a new feature. This is analogous to the step above from the simple regression to polynomial regression, where also more features are added by taking the sole predictor to the n-th power. The more dimensions you add, the easier it is to separate the samples with a flat hyperplane. This plane is then transformed back to the original n-dimensional space, getting wrinkled and crumpled on the way. By clever selecting the kernel function, the process can be performed without actually computing the transformation.


Like neural networks, SVMs can be used not only for classification, but also for regression. They also offer some parameters for optimizing and possibly overfitting the prediction process:


Kernel function. You normally use a RBF kernel (radial basis function, a symmetric kernel), but you also have the choice of other kernels, such as sigmoid, polynomial, and linear. Gamma, the width of the RBF kernel Cost parameter C, the ‘penalty’ for wrong classifications in the training samples.


An often used SVM is the libsvm library. It’s also available in R in the e1071 package. In the next and final part of this series I plan to describe a trading strategy using this SVM.


8. K-Nearest neighbor.


Compared with the heavy ANN and SVM stuff, that’s a nice simple algorithm with a unique property: It needs no training. So the samples are the model. You could use this algorithm for a trading system that learns permanently by simply adding more and more samples. The nearest neighbor algorithm computes the distances in feature space from the current feature values to the k nearest samples. A distance in n-dimensional space between two feature sets (x 1 .. x n ) and (y 1 .. y n ) is calculated just as in 2 dimensions:


The algorithm simply predicts the target from the average of the k target variables of the nearest samples, weighted by their inverse distances. It can be used for classification as well as for regression. Software tricks borrowed from computer graphics, such as an adaptive binary tree (ABT), can make the nearest neighbor search pretty fast. In my past life as computer game programmer, we used such methods in games for tasks like self-learning enemy intelligence. You can call the knn function in R for nearest neighbor prediction – or write a simple function in C for that purpose.


This is an approximation algorithm for unsupervised classification. It has some similarity, not only its name, to k-nearest neighbor. For classifying the samples, the algorithm first places k random points in the feature space. Then it assigns to any of those points all the samples with the smallest distances to it. The point is then moved to the mean of these nearest samples. This will generate a new samples assignment, since some samples are now closer to another point. The process is repeated until the assignment does not change anymore by moving the points, i. e. each point lies exactly at the mean of its nearest samples. We now have k classes of samples, each in the neighborhood of one of the k points.


This simple algorithm can produce surprisingly good results. In R, the kmeans function does the trick. An example of the k-means algorithm for classifying candle patterns can be found here: Unsupervised candlestick classification for fun and profit.


10. Naive Bayes.


This algorithm uses Bayes’ Theorem for classifying samples of non-numeric features (i. e. events ), such as the above mentioned candle patterns . Suppose that an event X (for instance, that the Open of the previous bar is below the Open of the current bar) appears in 80% of all winning samples. What is then the probability that a sample is winning when it contains event X ? It’s not 0.8 as you might think. The probability can be calculated with Bayes’ Theorem:


P(Y|X) is the probability that event Y (f. i. winning) occurs in all samples containing event X (in our example, Open(1) < Open(0) ). According to the formula, it is equal to the probability of X occurring in all winning samples (here, 0.8), multiplied by the probability of Y in all samples (around 0.5 when you were following my above advice of balanced samples) and divided by the probability of X in all samples.


If we are naive and assume that all events X are independent of each other, we can calculate the overall probability that a sample is winning by simply multiplying the probabilities P (X|winning) for every event X . This way we end up with this formula:


with a scaling factor s . For the formula to work, the features should be selected in a way that they are as independent as possible, which imposes an obstacle for using Naive Bayes in trading. For instance, the two events Close(1) < Close(0) and Open(1) < Open(0) are most likely not independent of each other. Numerical predictors can be converted to events by dividing the number into separate ranges.


The Naive Bayes algorithm is available in the ubiquitous e1071 R package.


11. Decision and regression trees.


Those trees predict an outcome or a numeric value based on a series of yes/no decisions, in a structure like the branches of a tree. Any decision is either the presence of an event or not (in case of non-numerical features) or a comparison of a feature value with a fixed threshold. A typical tree function, generated by Zorro’s tree builder, looks like this:


How is such a tree produced from a set of samples? There are several methods; Zorro uses the Shannon i nformation entropy , which already had an appearance on this blog in the Scalping article. At first it checks one of the features, let’s say x 1 . It places a hyperplane with the plane formula x 1 = t into the feature space. This hyperplane separates the samples with x 1 > t from the samples with x 1 < t . The dividing threshold t is selected so that the information gain – the difference of information entropy of the whole space, to the sum of information entropies of the two divided sub-spaces – is maximum. This is the case when the samples in the subspaces are more similar to each other than the samples in the whole space.


This process is then repeated with the next feature x 2 and two hyperplanes splitting the two subspaces. Each split is equivalent to a comparison of a feature with a threshold. By repeated splitting, we soon get a huge tree with thousands of threshold comparisons. Then the process is run backwards by pruning the tree and removing all decisions that do not lead to substantial information gain. Finally we end up with a relatively small tree as in the code above.


Decision trees have a wide range of applications. They can produce excellent predictions superior to those of neural networks or support vector machines. But they are not a one-fits-all solution, since their splitting planes are always parallel to the axes of the feature space. This somewhat limits their predictions. They can be used not only for classification, but also for regression, for instance by returning the percentage of samples contributing to a certain branch of the tree. Zorro’s tree is a regression tree. The best known classification tree algorithm is C5.0 , available in the C50 package for R.


For improving the prediction even further or overcoming the parallel-axis-limitation, an ensemble of trees can be used, called a random forest . The prediction is then generated by averaging or voting the predictions from the single trees. Random forests are available in R packages randomForest , ranger and Rborist .


استنتاج.


There are many different data mining and machine learning methods at your disposal. The critical question: what is better, a model-based or a machine learning strategy? There is no doubt that machine learning has a lot of advantages. You don’t need to care about market microstructure, economy, trader psychology, or similar soft stuff. You can concentrate on pure mathematics. Machine learning is a much more elegant, more attractive way to generate trade systems. It has all advantages on its side but one. Despite all the enthusiastic threads on trader forums, it tends to mysteriously fail in live trading.


Every second week a new paper about trading with machine learning methods is published (a few can be found below). Please take all those publications with a grain of salt. According to some papers, phantastic win rates in the range of 70%, 80%, or even 85% have been achieved. Although win rate is not the only relevant criterion – you can lose even with a high win rate – 85% accuracy in predicting trades is normally equivalent to a profit factor above 5. With such a system the involved scientists should be billionaires meanwhile. Unfortunately I never managed to reproduce those win rates with the described method, and didn’t even come close. So maybe a lot of selection bias went into the results. Or maybe I’m just too stupid.


Compared with model based strategies, I’ve seen not many successful machine learning systems so far. And from what one hears about the algorithmic methods by successful hedge funds, machine learning seems still rarely to be used. But maybe this will change in the future with the availability of more processing power and the upcoming of new algorithms for deep learning.


Classification using deep neural networks: Dixon. et. al.2018 Predicting price direction using ANN & SVM: Kara. et. al.2018 Empirical comparison of learning algorithms: Caruana. et. al.2006 Mining stock market tendency using GA & SVM: Yu. Wang. Lai.2005.


The next part of this series will deal with the practical development of a machine learning strategy.


30 thoughts on “Better Strategies 4: Machine Learning”


مشاركة لطيفة. There is a lot of potential in these approach towards the market.


Btw are you using the code editor which comes with zorro? how is it possible to get such a colour configuration?


The colorful script is produced by WordPress. You can’t change the colors in the Zorro editor, but you can replace it with other editors that support individual colors, for instance Notepad++.


Is it then possible that notepad detects the zorro variables in the scripts? I mean that BarPeriod is remarked as it is with the zorro editor?


Theoretically yes, but for this you had to configure the syntax highlighting of Notepad++, and enter all variables in the list. As far as I know Notepad++ can also not be configured to display the function description in a window, as the Zorro editor does. There’s no perfect tool…


Concur with the final paragraph. I have tried many machine learning techniques after reading various ‘peer reviewed’ papers. But reproducing their results remains elusive. When I live test with ML I can’t seem to outperform random entry.


ML fails in live? Maybe the training of the ML has to be done with price data that include as well historical spread, roll, tick and so on?


I think reason #1 for live failure is data mining bias, caused by biased selection of inputs and parameters to the algo.


Thanks to the author for the great series of articles.


However, it should be noted that we don’t need to narrow our view with predicting only the next price move. It may happen that the next move goes against our trade in 70% of cases but it still worth making a trade. This happens when the price finally does go to the right direction but before that it may make some steps against us. If we delay the trade by one price step we will not enter the mentioned 30% of trades but for that we will increase the result of the remained 70% by one price step. So the criteria is which value is higher: N*average_result or 0.7*N*(avergae_result + price_step).


مشاركة لطيفة. If you just want to play around with some machine learning, I implemented a very simple ML tool in python and added a GUI. It’s implemented to predict time series.


Thanks JCL I found very interesting your article. I would like to ask you, from your expertise in trading, where can we download reliable historical forex data? I consider it very important due to the fact that Forex market is decentralized.


شكرا مقدما!


There is no really reliable Forex data, since every Forex broker creates their own data. They all differ slightly dependent on which liquidity providers they use. FXCM has relatively good M1 and tick data with few gaps. You can download it with Zorro.


Thanks for writing such a great article series JCL… a thoroughly enjoyable read!


I have to say though that I don’t view model-based and machine learning strategies as being mutually exclusive; I have had some OOS success by using a combination of the elements you describe.


To be more exact, I begin the system generation process by developing a ‘traditional’ mathematical model, but then use a set of online machine learning algorithms to predict the next terms of the various different time series (not the price itself) that are used within the model. The actual trading rules are then derived from the interactions between these time series. So in essence I am not just blindly throwing recent market data into an ML model in an effort to predict price action direction, but instead develop a framework based upon sound investment principles in order to point the models in the right direction. I then data mine the parameters and measure the level of data-mining bias as you’ve described also.


It’s worth mentioning however that I’ve never had much success with Forex.


Anyway, best of luck with your trading and keep up the great articles!


شكرا لنشر هذه السلسلة الصغيرة العظيمة جسل.


I recently studied a few latest papers about ML trading, deep learning especially. Yet I found that most of them valuated the results without risk-adjusted index, i. e., they usually used ROC curve, PNL to support their experiment instead of Sharpe Ratio, for example.


Also, they seldom mentioned about the trading frequency in their experiment results, making it hard to valuate the potential profitability of those methods. لماذا هذا؟ Do you have any good suggestions to deal with those issues?


ML papers normally aim for high accuracy. Equity curve variance is of no interest. This is sort of justified because the ML prediction quality determines accuracy, not variance.


Of course, if you want to really trade such a system, variance and drawdown are important factors. A system with lower accuracy and worse prediction can in fact be preferable when it’s less dependent on market condictions.


“In fact the most popular – and surprisingly profitable – data mining method works without any fancy neural networks or support vector machines.”


Would you please name those most popular & surprisingly profitable ones. So I could directly use them.


I was referring to the Indicator Soup strategies. For obvious reasons I can’t disclose details of such a strategy, and have never developed such systems myself. We’re merely coding them. But I can tell that coming up with a profitable Indicator Soup requires a lot of work and time.


Well, i am just starting a project which use simple EMAs to predict price, it just select the correct EMAs based on past performance and algorithm selection that make some rustic degree of intelligence.


Jonathan. orrego@gmail offers services as MT4 EA programmer.


Thanks for the good writeup. It in reality used to be a leisure account it.


Look complicated to more delivered agreeable from you!


By the way, how could we be in contact?


There are following issues with ML and with trading systems in general which are based on historical data analysis:


1) Historical data doesn’t encode information about future price movements.


Future price movement is independent and not related to the price history. There is absolutely no reliable pattern which can be used to systematically extract profits from the market. Applying ML methods in this domain is simply pointless and doomed to failure and is not going to work if you search for a profitable system. Of course you can curve fit any past period and come up with a profitable system for it.


The only thing which determines price movement is demand and supply and these are often the result of external factors which cannot be predicted. For example: a war breaks out somewhere or other major disaster strikes or someone just needs to buy a large amount of a foreign currency for some business/investment purpose. These sort of events will cause significant shifts in the demand supply structure of the FX market . As a consequence, prices begin to move but nobody really cares about price history just about the execution of the incoming orders. An automated trading system can only be profitable if it monitors a significant portion of the market and takes the supply and demand into account for making a trading decision. But this is not the case with any of the systems being discussed here.


2) Race to the bottom.


Even if (1) wouldn’t be true and there would be valuable information encoded in historical price data, you would still face following problem: there are thousands of gold diggers out there, all of them using similar methods and even the same tools to search for profitable systems and analyze the same historical price data. As a result, many of them will discover the same or very similar “profitable” trading systems and when they begin actually trading those systems, they will become less and less profitable due to the nature of the market.


The only sure winners in this scenario will be the technology and tool vendors.


I will be still keeping an eye on your posts as I like your approach and the scientific vigor you apply. Your blog is the best of its kind – keep the good work!


One hint: there are profitable automated systems, but they are not based on historical price data but on proprietary knowledge about the market structure and operations of the major institutions which control these markets. Let’s say there are many inefficiencies in the current system but you absolutely have no chance to find the information about those by analyzing historical price data. Instead you have to know when and how the institutions will execute market moving orders and front run them.


Thanks for the extensive comment. I often hear these arguments and they sound indeed intuitive, only problem is that they are easily proven wrong. The scientific way is experiment, not intuition. Simple tests show that past and future prices are often correlated – otherwise every second experiment on this blog had a very different outcome. Many successful funds, for instance Jim Simon’s Renaissance fund, are mainly based on algorithmic prediction.


One more thing: in my comment I have been implicitly referring to the buy side (hedge funds, traders etc) not to the sell side (market makers, banks). The second one has always the edge because they sell at the ask and buy at the bid, pocketing the spread as an additional profit to any strategy they might be running. Regarding Jim Simon’s Renaissance: I am not so sure if they have not transitioned over the time to the sell side in order to stay profitable. There is absolutely no information available about the nature of their business besides the vague statement that they are using solely quantitative algorithmic trading models…


Thanks for the informative post!


Regarding the use of some of these algorithms, a common complaint which is cited is that financial data is non-stationary…Do you find this to be a problem? Couldn’t one just use returns data instead which is (I think) stationary?


Yes, this is a problem for sure. If financial data were stationary, we’d all be rich. I’m afraid we have to live with what it is. Returns are not any more stationary than other financial data.


Hello sir, I developed some set of rules for my trading which identifies supply demand zones than volume and all other criteria. Can you help me to make it into automated system ?? If i am gonna do that myself then it can take too much time. Please contact me at svadukia@gmail if you are interested.


Sure, please contact my employer at info@opgroup. de. They’ll help.


I have noticed you don’t monetize your page, don’t waste your traffic,


you can earn extra bucks every month because you’ve got high quality content.


If you want to know how to make extra $$$, search for: Mrdalekjd methods for $$$


Technical analysis has always been rejected and looked down upon by quants, academics, or anyone who has been trained by traditional finance theories. I have worked for proprietary trading desk of a first tier bank for a good part of my career, and surrounded by those ivy-league elites with background in finance, math, or financial engineering. I must admit none of those guys knew how to trade directions. They were good at market making, product structures, index arb, but almost none can making money trading directions. لماذا ا؟ Because none of these guys believed in technical analysis. Then again, if you are already making your millions why bother taking the risk of trading direction with your own money. For me luckily my years of training in technical analysis allowed me to really retire after laying off from the great recession. I look only at EMA, slow stochastics, and MACD; and I have made money every year since started in 2009. Technical analysis works, you just have to know how to use it!!


How To Use A Support Vector Machine (SVM) In Daily Trading?


As a trader it is very important for you to enter the trade in the right direction. For example, you should be pretty sure the market is going to go up before you enter into a buy trade. If you enter a buy trade and market goes down, trade will end up hitting stop loss. If you have a method that can predict market direction with an accuracy above 70%, you can cut your overall risk of losing by 70%. In the last post I told you about R language and software and how you can use R in improving your trading system . R is a powerful statistical analysis software and is open source. There are more than 2000 R packages that are available to you that you can use to make your predictive models.


Our aim is to improve our trading system. The strategy is to combine your predictive statistical model with your naked trading model that is solely based on the technical analysis of price action. For example you spot a Gartley pattern on your chart and you have a buy signal. Your statistical predictive model tells you there is a 75% chance market will go down today. ماذا عليك ان تفعل؟ You should not enter into a buy trade. You will see by the end of the day you have saved yourself from a bad trade. In this post we will discuss how to forecast market direction using a Support Vector Machine (SVM). You can use a support vector machine on any time frame. Suppose you are planning to enter into a buy trade on H1 timeframe. Your SVM model predicts that next candle to be bearish. You can use this prediction to enter at a much better price in the next hour.


How To Use Support Vector Machine (SVM) In Predicting Market Direction On Any Timeframe?


You should download R software and RStudio software and install it before you continue with this post. Support Vector Machines are non-linear classifiers that use a kernel function to transform a non-linear classification problem into a linear classification problem. Watch the video below that explains what an SVM is:


Support Vector Machine is an important Machine Learning Algorithm. Now you don’t need to master how to do the modelling with an SVM. You should just have a broad understanding what is this algorithm and how you can use to cut your losses in your daily trading.


SV type: eps-svr (regression)


parameter : epsilon = 0.1 cost C = 5.


Gaussian Radial Basis kernel function.


Hyperparameter : sigma = 0.05.


Number of Support Vectors : 1884.


Objective Function Value : -3870.229.


Training error : 0.285461.


Cross validation error : 0.08664.


وGT. #calculate the time taken to make an SVM.


وGT. user system elapsed.


As you can see from the above calculations it took around 6.65 seconds for R to perform all the above calculations. The training error is 28% meaning the predictive accuracy of this SVM Model is 72%. We have used a radial basis function as the kernel. We need to do some tweaking and see if we can improve the predictive accuracy. The above calculations have been made using 5 lags of simple returns. With these 5 simple return lags we are getting a training error of 28%. Let’s repeat the calculations with 10 lags and see if we succeed in reducing the training.


As you can see above we did the calculations with 10 lags and were able to reduce the training error to 22% meaning we achieved a predictive accuracy of 78%. The time taken by R to do all the calculations is just 5.13 seconds which means we can also use our model on intraday timeframes like M15 and M30. We can trade binary options with this model on intraday timeframes of M15 and M30. Training error is always an overestimate. When we do out of sample testing, we will get an error that will be something between 22% to 28%. As long as we have a predictive accuracy above 70%, we can use this SVM Model in our daily trading. Now let’s do the calculations for the intraday timeframe of M15. This time we make the prediction for EURUSD.


These were the calculations for EURUSDM15 candles. As you can see R made the calculations pretty fast in 5 seconds. The training error is approximately 25% meaning we achieved a predictive accuracy of 75%. Now if we tweak the model more we can make the predictive accuracy better.


هذا ما افعله. I have this model make the prediction. As you have seen above this model hardly takes a few seconds to predict the next candle. Once I have the prediction, I use my candlestick trading system and see if it confirms with the prediction. When both the predictions confirm each other, I open the trade otherwise I skip the trade. This helps in reducing the losses.


You can see in the above calculations we reduced the number of lags from 10 to 5. We reduced the time of calculations by 1 second by training error went up to 30%. This is an indication that we should not try to reduce the number of lags. As you can see we can perform these calculations in just a few seconds. After this statistical modelling we know with at least 70% certainty the direction of the next candle. If the prediction is an up candle, we should avoid a sell trade. Use your knowledge of candlestick patterns and enter into a buy trade .


0 تعليق.


تحميل نظام الفوركس بسيط مجانا أن الزوجي الحساب كل شهر مع 3-4 انخفاض المخاطر مجموعة وتنسى الصفقات على H4 الإطار الزمني ويمكن أيضا تداول الخيارات الثنائية على M5، M15 و M30 الأطر الزمنية!


معلوماتك آمنة 100٪ معنا ولن تكون مشتركة.


كوبيرايت & كوبي؛ 2018 · Forex. TradingNinja · جميع الحقوق محفوظة.


الحصول على استراتيجية الخيارات الثنائية التي لديها 92٪ متوسط ​​وينرات مجانا!

No comments:

Post a Comment